Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/jquery.mousewheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,43 @@
version: "@VERSION",

setup: function() {
this.addEventListener( "wheel", handler, false );
// Use passive event listeners if supported
var passiveSupported = false;
try {
var opts = Object.defineProperty({}, "passive", {
get: function() {
passiveSupported = true;
}
});
window.addEventListener("test", null, opts);
} catch (e) {}
this.addEventListener(
"wheel",
handler,
passiveSupported ? { passive: true } : false
);

// Store the line height and page height for this particular element
$.data( this, "mousewheel-line-height", special.getLineHeight( this ) );
$.data( this, "mousewheel-page-height", special.getPageHeight( this ) );
},

teardown: function() {
this.removeEventListener( "wheel", handler, false );
// Use passive event listeners if supported
var passiveSupported = false;
try {
var opts = Object.defineProperty({}, "passive", {
get: function() {
passiveSupported = true;
}
});
window.addEventListener("test", null, opts);
} catch (e) {}
this.removeEventListener(
"wheel",
handler,
passiveSupported ? { passive: true } : false
);

// Clean up the data we added to the element
$.removeData( this, "mousewheel-line-height" );
Expand Down