From 5d771abbf2d0923a759837ffd579d653a5538dcd Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 13 Dec 2013 09:22:13 -0500 Subject: [PATCH] Attempt to beter handle older browsers that use a wheelDelta based on 120 --- ChangeLog.md | 1 + jquery.mousewheel.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index fabdfe8cf..d1ad85d99 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ ## 3.1.7-pre * Better handle the `deltaMode` values 1 (lines) and 2 (pages) +* Attempt to better handle older browsers that use a wheelDelta based on 120 ## 3.1.6 diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index d242796ff..d87724aae 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -139,6 +139,17 @@ lowestDelta = absDelta; } + // Assuming that if the lowestDelta is 120, then that the browser + // is treating this as an older mouse wheel event. + // We'll divide it by 40 to try and get a more usable deltaFactor. + if ( lowestDelta === 120 ) { + // Divide all the things by 40! + delta /= 40; + deltaX /= 40; + deltaY /= 40; + lowestDelta /= 40; + } + // Get a whole, normalized value for the deltas delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);