Skip to content

Instantly share code, notes, and snippets.

@basilalex
Created July 16, 2017 07:25
Show Gist options
  • Save basilalex/51c3185970031079c38ce12a78dce8a3 to your computer and use it in GitHub Desktop.
Save basilalex/51c3185970031079c38ce12a78dce8a3 to your computer and use it in GitHub Desktop.
scrollDirection
let lastScrollTop = 0;
function scrollDirection() {
const st = window.pageYOffset || document.documentElement.scrollTop;
if (st > lastScrollTop) {
// downscroll code
} else {
// upscroll code
}
lastScrollTop = st;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment