Skip to content

Instantly share code, notes, and snippets.

@fallenleavesguy
Forked from nathansmith/scroll-offset.js
Created January 13, 2020 14:18
Show Gist options
  • Save fallenleavesguy/e14ac5609d322205e1b53d8e5c622f4f to your computer and use it in GitHub Desktop.
Save fallenleavesguy/e14ac5609d322205e1b53d8e5c622f4f to your computer and use it in GitHub Desktop.
Check if the user is scrolled to the bottom of the page.
window.onscroll = function() {
var d = document.documentElement;
var offset = d.scrollTop + window.innerHeight;
var height = d.offsetHeight;
console.log('offset = ' + offset);
console.log('height = ' + height);
if (offset === height) {
console.log('At the bottom');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment