Last active
November 27, 2023 04:51
-
-
Save nathansmith/8939548 to your computer and use it in GitHub Desktop.
Check if the user is scrolled to the bottom of the page.
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
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
Niceee 👏
But there's a problem with these solutions.
When the page is Zoomed.
The numbers of the
height
stays float