Created
July 16, 2017 07:25
-
-
Save basilalex/51c3185970031079c38ce12a78dce8a3 to your computer and use it in GitHub Desktop.
scrollDirection
This file contains 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
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