Created
February 7, 2019 17:04
-
-
Save iamchristough/13aa866c6f391e1cc49f1fd1d4d28ccf to your computer and use it in GitHub Desktop.
scrollToTop
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
const scrollToTop = () => { | |
const c = document.documentElement.scrollTop || document.body.scrollTop; | |
if (c > 0) { | |
window.requestAnimationFrame(scrollToTop); | |
window.scrollTo(0, c - c / 8); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment