To detect when a website visitor has stopped vertical up/down scrolling and the direction the are scrolling, up or down, if they have not stopped scrolling and are currently scrolling, involves setting a timer that stores the window.pageYoffset
in a global variable and then comparing that value to the current window.pageYoffset
.
If the visitor stopped scrolling there will be no difference between the global variable and the value of window.pageYoffset
and teh return of the function will be 0.
If the website visitor is currently scrolling then the function will return ...
Feel free to right click this page to view the source to see how to use this Javascript code to detect if scrolling has stopped or what direction the website visitor is scrolling.