Skip to content

Unpaired bindEvent/unbindEvent with reload() #226

@priandsf

Description

@priandsf

We just found out that a call to reload() does not unbind the resize/scroll events, while the events are bound again when the data is loaded.
Steps to reproduce:

  • Launch Reload100 demo app
  • Open your JS debugger and put a breakpoint on both bindEvents() & unbindEvents()
  • Click the reload button from the demo page. The debugger breaks on bindEvents but not on unbindEvents

Possible solutions:

  • add a call to unbindEvent() within reload
  • keep a flag defining if the events are already bound like bellow:
        let eventBound = false;
        function bindEvents() {
          if(!eventBound) {
            eventBound = true;
            viewport.bind('resize', resizeAndScrollHandler);
            viewport.bind('scroll', resizeAndScrollHandler);          
          }
        }
        function unbindEvents() {
          if(eventBound) {
            eventBound = false;
            viewport.unbind('resize', resizeAndScrollHandler);
            viewport.unbind('scroll', resizeAndScrollHandler);
          }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy