Coding task · JavaScript and TypeScript course · Module 8: Events and the DOM

Exercise: Scroll Events

Create a navbar that changes while scrolling the page.

Task

The index.html file has a #navbar bar, and style.css hides it when it has the hidden class. The script remembers the last scroll position (window.scrollY). Fill in the blanks: ___BLANK1___ is the page scroll event listened to on window, and ___BLANK2___ is the comparison operator that detects scrolling down (the new position is greater than the previous one). The bar should hide when scrolling down and come back when scrolling up.