Last active
May 24, 2018 03:50
-
-
Save karki-dennis/95beffcd1ab92e34fd6b7ecde401ba2c to your computer and use it in GitHub Desktop.
scroll top and down detect
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
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