Closed
Description
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 onunbindEvents
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);
}
}