Last active
September 17, 2019 13:45
-
-
Save electerious/7ad886432f55cfcb4222 to your computer and use it in GitHub Desktop.
Cross-browser scroll element fetching
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
const scrollroot = (() => { | |
if ('scrollingElement' in document) return document.scrollingElement | |
const initial = document.documentElement.scrollTop | |
document.documentElement.scrollTop = initial + 1 | |
const updated = document.documentElement.scrollTop | |
document.documentElement.scrollTop = initial | |
return (updated > initial ? document.documentElement : document.body) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
Description:
Source:
https://medium.com/@bdc/stripe-open-source-behind-the-scenes-59790999dea0