/
githubmirror
/
50projects50days
Обзор
Документация
Войти
/
githubmirror
/
50projects50days
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
scroll-animation/script.js
19 строк
422 B
Brad Traversy
Scroll animation
13 ноя 2020, 18:23
13 ноя 2020, 18:23
f115c80
Код
Авторство
О чём код?
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') } }) }