Skip to content

Instantly share code, notes, and snippets.

@ron4stoppable
Last active December 23, 2018 15:09
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 ron4stoppable/750381b30bd145c44d1f48729fc0124f to your computer and use it in GitHub Desktop.
Save ron4stoppable/750381b30bd145c44d1f48729fc0124f to your computer and use it in GitHub Desktop.
Get proper scroll/page-offset value, works in all browsers, over all platforms (as far as I have tested)
// to get proper scroll/page-offset value
// works in all browsers, over all platforms (as far as I have tested)
// this basically is for the different property in iOS browser & Safari
const scrollTop = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment