Created
April 12, 2021 14:23
-
-
Save samg11/5a99bd1abafe9900801f42e63e791e74 to your computer and use it in GitHub Desktop.
Chatre: get distance from bottom of scroll with jquery. Should console log distance from bottom when scrolling.
This file contains 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
let scrollBarHeight; | |
// ONLY RUN WHEN SCROLLED TO BOTTOM | |
window.scrollBarHeight = (document.querySelector("#messages").scrollHeight) - ($("#messages").height() + $("#messages").scrollTop()); | |
// END OF ONLY RUN WHEN SCROLLED TO BOTTOM | |
$("#messages").scroll(() => { | |
const a = document.querySelector("#messages").scrollHeight; | |
const b = $("#messages").height() * 2; | |
const c = $("#messages").height() - $("#messages").scrollTop(); | |
const d = window.scrollBarHeight; | |
console.log(a - b + c - d); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment