Attempt to beter handle older browsers that use a wheelDelta based on 120

This commit is contained in:
Brandon Aaron
2013-12-13 09:22:13 -05:00
parent 41b980a423
commit 5d771abbf2
2 changed files with 12 additions and 0 deletions

View File

@@ -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

View File

@@ -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);