Skip to content

Instantly share code, notes, and snippets.

@Korveld
Last active November 13, 2019 22:55
Show Gist options
  • Select an option

  • Save Korveld/0463390c9ac443a5cf0ff20d5b93eb99 to your computer and use it in GitHub Desktop.

Select an option

Save Korveld/0463390c9ac443a5cf0ff20d5b93eb99 to your computer and use it in GitHub Desktop.
var lastScrollTop = 0;
$(window).scroll(function(event) {
var st = $(this).scrollTop();
if (st > lastScrollTop) {
//Scroll Down
}
else if (st == lastScrollTop) {
//do nothing
//In IE this is an important condition because there seems to be some instances where the last scrollTop is equal to the new one
}
else {
//Scroll Up
}
lastScrollTop = st;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment