Detecting scroll direction with JavaScript

Detecting scroll direction with just pure JavaScript is quite straightforward. First step is to create an event listener for a scroll event. Event handler function that we pass to this listener is called every time user scrolls the page up or down. Inside the event handler we compare the current Y position and the previous … Read more