Created
July 25, 2020 16:05
-
-
Save iceener/f574f7a06e5164cc45ca8e6d48a94483 to your computer and use it in GitHub Desktop.
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
const scrollTop = () => { | |
const scrollPos = document.documentElement.scrollTop || document.body.scrollTop; | |
if (scrollPos > 0) { | |
window.requestAnimationFrame(scrollTop); | |
window.scrollTo(0, scrollPos - scrollPos / 8); | |
} | |
}; | |
// How2use? | |
scrollToTop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment