Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Last active March 21, 2016 17:25
Show Gist options
  • Save andreasvirkus/bfd03098eed00f2e6d99 to your computer and use it in GitHub Desktop.
Save andreasvirkus/bfd03098eed00f2e6d99 to your computer and use it in GitHub Desktop.
$(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