Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Last active November 5, 2019 19:14
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 kgriffs/3de5b2ba94a79229a5f21d9f1342f243 to your computer and use it in GitHub Desktop.
Save kgriffs/3de5b2ba94a79229a5f21d9f1342f243 to your computer and use it in GitHub Desktop.
Scroll to bottom of page using vanilla JS to trigger lazy loading
const scrollingElement = document.scrollingElement
const viewport_height = scrollingElement.clientHeight
for (let pos = 0; pos < scrollingElement.scrollHeight; pos += viewport_height) {
scrollBy(0, viewport_height)
}
@kgriffs
Copy link
Author

kgriffs commented Nov 5, 2019

To go back to the top:

document.scrollingElement.scrollTop = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment