You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
422 B
19 lines
422 B
const boxes = document.querySelectorAll('.box')
|
|
|
|
window.addEventListener('scroll', checkBoxes)
|
|
|
|
checkBoxes()
|
|
|
|
function checkBoxes() {
|
|
const triggerBottom = window.innerHeight / 5 * 4
|
|
|
|
boxes.forEach(box => {
|
|
const boxTop = box.getBoundingClientRect().top
|
|
|
|
if(boxTop < triggerBottom) {
|
|
box.classList.add('show')
|
|
} else {
|
|
box.classList.remove('show')
|
|
}
|
|
})
|
|
} |