windows scroll condition 1

windows scroll condition

window.onscroll =  ()  =>{
    // called when the window is scrolled.
    if (window.scrollY >= 30) {

        //your event
        console.log(window.scrollY);

    } else {
        //your event
    }
}

Here is what the above code is Doing:
1. We are listening for the scroll event on the window object.
2. We are checking if the scrollY property of the window object is greater than or equal to 30.
3. If the condition is true, we are logging the value of the scrollY property to the console.
4. If the condition is false, we are logging the value of the scrollY property to the console.

Similar Posts