Last active
June 2, 2021 07:29
-
-
Save YasinKuralay/3282ac9458746d78ad86d80b82071fdf to your computer and use it in GitHub Desktop.
JS Document height
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
// Calculation on load because otherwise IOS devices return an unreliable height variable ( different values at different places ) | |
window.addEventListener("load", () => { | |
// See stackoverflow post https://stackoverflow.com/a/1147768 | |
let height = Math.max( | |
document.body.scrollHeight, | |
document.body.offsetHeight, | |
html.clientHeight, | |
html.scrollHeight, | |
html.offsetHeight | |
); | |
}); |
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
// If scroll direction is upwards, and we are not at the bottom 15px | |
if ( | |
window.pageYOffset < lastKnownScrollPosition && | |
window.innerHeight + window.pageYOffset <= height - 15 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment