Day # 55: Scroll animation



Scrolling is one of those functionalities that we, as frontend developers, need to be able to handle, control and optimize. With that in mind, I decided to look for cool effects or animations that are activated by scrolling.

For today’s project, I decided to work on an animation that displays content as soon as you scroll down. The key here is to check on the innerHeight property of the window, and then what we basically need to do is to toggle classes that allow to display or hide those boxes of content: 


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')

        }

    })

}


Comments

Popular posts from this blog

Day # 19: Checkbox animation

Day # 12: Typewriter Effect

Day # 53: Icon text