Skip to content

Instantly share code, notes, and snippets.

@devxom
Last active July 26, 2019 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devxom/e040b9cb00c281b2bf0f3837740b3d53 to your computer and use it in GitHub Desktop.
Save devxom/e040b9cb00c281b2bf0f3837740b3d53 to your computer and use it in GitHub Desktop.
function getScrollTopPosition(){
return document.documentElement.scrollTop || document.body.scrollTop || document.body.scrollTop || window.pageYOffset || 0;
}
// because it's so fucking difficult to detect the scrolling element, just move them all
function moveToScrollTop(amount) {
document.documentElement.scrollTop = amount;
document.body.parentNode.scrollTop = amount;
document.body.scrollTop = amount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment