Skip to content

Instantly share code, notes, and snippets.

@abozhilov
Last active September 29, 2016 14:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save abozhilov/452e75db5df5f33578f6718d1ad52fb0 to your computer and use it in GitHub Desktop.
scroll.js
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