Skip to content

Unpaired bindEvent/unbindEvent with reload() #226

Closed
@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