Skip to content

Commit 278e99f

Browse files
committed
Attempt to better handle multiple devices that give a different
lowestDelta value
1 parent 0e20857 commit 278e99f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

jquery.mousewheel.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
2424
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
2525
slice = Array.prototype.slice,
26-
lowestDelta;
26+
nullLowestDeltaTimeout, lowestDelta;
2727

2828
if ( $.event.fixHooks ) {
2929
for ( var i = toFix.length; i; ) {
@@ -116,7 +116,18 @@
116116
// Add event and delta to the front of the arguments
117117
args.unshift(event, delta, deltaX, deltaY);
118118

119+
// Clearout lowestDelta after sometime to better
120+
// handle multiple device types that give different
121+
// a different lowestDelta
122+
// Ex: trackpad = 3 and mouse wheel = 120
123+
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
124+
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
125+
119126
return ($.event.dispatch || $.event.handle).apply(this, args);
120127
}
121128

129+
function nullLowestDelta() {
130+
lowestDelta = null;
131+
}
132+
122133
}));

0 commit comments

Comments
 (0)