Skip to content

Commit

Permalink
Events: Unbind scroll events properly
Browse files Browse the repository at this point in the history
  • Loading branch information
apsdehal authored and arschmitz committed Jul 4, 2016
1 parent 0756d6c commit 76e9a47
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/events/scroll.js
Expand Up @@ -59,8 +59,7 @@ $.event.special.scrollstart = {
event.type = originalEventType;
}

// iPhone triggers scroll after a small delay; use touchmove instead
$this.bind( scrollEvent, function( event ) {
var scrollStartHandler = $.event.special.scrollstart.handler = function ( event ) {

if ( !$.event.special.scrollstart.enabled ) {
return;
Expand All @@ -74,10 +73,13 @@ $.event.special.scrollstart = {
timer = setTimeout( function() {
trigger( event, false );
}, 50 );
} );
};

// iPhone triggers scroll after a small delay; use touchmove instead
$this.on( scrollEvent, scrollStartHandler );
},
teardown: function() {
$( this ).unbind( scrollEvent );
$( this ).off( scrollEvent, $.event.special.scrollstart.handler );
}
};

Expand Down

0 comments on commit 76e9a47

Please sign in to comment.