Created
March 6, 2014 15:57
-
-
Save wiledal/9392815 to your computer and use it in GitHub Desktop.
Normalize scroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Provide "originalEvent" of DOMMouseScroll and mousewheel | |
var o = event; | |
var d = o.detail; | |
var w = o.wheelDelta || o.deltaY; | |
var n = 225; | |
var n1 = n - 1; | |
var d = (d ? (w && (f = w / d) ? d / f : -d / 1.35) : w / 120); | |
var d = (d < 1 ? (d < -1 ? (-Math.pow(d, 2) - n1) / n : d) : (Math.pow(d, 2) + n1) / n); | |
event.delta = Math.min(Math.max(d / 2, -1), 1); | |
return event; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment