Skip to content

Instantly share code, notes, and snippets.

@SnowyPainter
Created April 16, 2020 07:43
Show Gist options
  • Save SnowyPainter/846d4097f7af8985a42bf804c1320e96 to your computer and use it in GitHub Desktop.
Save SnowyPainter/846d4097f7af8985a42bf804c1320e96 to your computer and use it in GitHub Desktop.
window.addEventListener("load", () => {
window.onscroll = (event) => {
const objs = document.getElementsByClassName("scroll-fadein")
for (let i = 0; i < objs.length; i++) {
const bottomObj = objs[i].offsetTop + objs[i].scrollHeight;
const bottomWindow = window.scrollY + window.outerHeight;
if (bottomWindow > bottomObj) {
objs[i].style.opacity = "1"
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment