-
-
Save abozhilov/452e75db5df5f33578f6718d1ad52fb0 to your computer and use it in GitHub Desktop.
scroll.js
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
var pos = 0; | |
window.addEventListener('scroll', function () { | |
pos = document.body.scrollTop * (100 / document.body.scrollHeight) | |
}) | |
window.addEventListener('resize', function () { | |
var scrollTop = pos * (document.body.scrollHeight / 100) | |
window.scrollTo(0, scrollTop) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment