Last active
March 21, 2016 17:25
-
-
Save andreasvirkus/bfd03098eed00f2e6d99 to your computer and use it in GitHub Desktop.
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
$(window).on('mousewheel DOMMouseScroll touchmove', function (e) { | |
var direction = (function () { | |
var delta, | |
compareEvent; | |
if (e.type ==='touchmove') { | |
compareEvent = 'touchmove'; | |
} else { | |
compareEvent = 'DOMMouseScroll'; | |
} | |
delta = e.type === compareEvent ? | |
e.originalEvent.detail * -40 : | |
e.originalEvent.wheelDelta; | |
return delta > 0 ? 0 : 1; | |
}()); | |
if (direction === 1) { | |
// scroll down | |
} | |
if (direction === 0) { | |
// scroll up | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment