Skip to content

Commit c7a2d66

Browse files
committed
Fix the handling of older 120 based deltas.
1 parent cafeaf9 commit c7a2d66

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

jquery.mousewheel.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
22
* Licensed under the MIT License (LICENSE.txt).
33
*
4-
* Version: 3.1.7
4+
* Version: 3.1.8-pre
55
*
66
* Requires: jQuery 1.2.2+
77
*/
@@ -23,7 +23,7 @@
2323
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
2424
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
2525
slice = Array.prototype.slice,
26-
nullLowestDeltaTimeout, lowestDelta;
26+
oldMode, nullLowestDeltaTimeout, lowestDelta;
2727

2828
if ( $.event.fixHooks ) {
2929
for ( var i = toFix.length; i; ) {
@@ -32,7 +32,7 @@
3232
}
3333

3434
var special = $.event.special.mousewheel = {
35-
version: '3.1.6',
35+
version: '3.1.8-pre',
3636

3737
setup: function() {
3838
if ( this.addEventListener ) {
@@ -137,17 +137,23 @@
137137

138138
if ( !lowestDelta || absDelta < lowestDelta ) {
139139
lowestDelta = absDelta;
140+
141+
// Assuming that if the lowestDelta is 120, then that the browser
142+
// is treating this as an older mouse wheel event.
143+
// We'll divide it by 40 to try and get a more usable deltaFactor.
144+
if ( lowestDelta === 120 ) {
145+
oldMode = true;
146+
lowestDelta /= 40;
147+
}
140148
}
141149

142-
// Assuming that if the lowestDelta is 120, then that the browser
143-
// is treating this as an older mouse wheel event.
144-
// We'll divide it by 40 to try and get a more usable deltaFactor.
145-
if ( lowestDelta === 120 ) {
150+
// When in oldMode the delta is based on 120. We devide
151+
// by 40 to try and get a more usable deltaFactor.
152+
if ( oldMode ) {
146153
// Divide all the things by 40!
147-
delta /= 40;
148-
deltaX /= 40;
149-
deltaY /= 40;
150-
lowestDelta /= 40;
154+
delta /= 40;
155+
deltaX /= 40;
156+
deltaY /= 40;
151157
}
152158

153159
// Get a whole, normalized value for the deltas
@@ -179,6 +185,7 @@
179185

180186
function nullLowestDelta() {
181187
lowestDelta = null;
188+
oldMode = null;
182189
}
183190

184191
}));

0 commit comments

Comments
 (0)