Skip to content

Instantly share code, notes, and snippets.

@StrongerMyself
Created November 16, 2016 03:07
Show Gist options
  • Save StrongerMyself/886b8b6bb8cfa58763310d75b14c07f5 to your computer and use it in GitHub Desktop.
Save StrongerMyself/886b8b6bb8cfa58763310d75b14c07f5 to your computer and use it in GitHub Desktop.
var $window = $(window),
lastScrollTop = 0;
function onScroll (e) {
var top = $window.scrollTop();
if (lastScrollTop > top) {
console.log('top');
} else if (lastScrollTop < top) {
console.log('down');
}
lastScrollTop = top;
}
$window.on('scroll', onScroll);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment