Skip to content

Instantly share code, notes, and snippets.

@karki-dennis
Last active May 24, 2018 03:50
Show Gist options
  • Save karki-dennis/95beffcd1ab92e34fd6b7ecde401ba2c to your computer and use it in GitHub Desktop.
Save karki-dennis/95beffcd1ab92e34fd6b7ecde401ba2c to your computer and use it in GitHub Desktop.
scroll top and down detect
var lastScrollTop = 0;
$(window).scroll(function (event) {
var st = $(this).scrollTop();
if (st > lastScrollTop) {
// downscroll code
} else {
// upscroll code
}
lastScrollTop = st;
});
//Pure js
$('#foo').bind('mousewheel', function(e){
if(e.originalEvent.wheelDelta /120 > 0) {
alert('up');
}
else{
alert('down');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment