I got this simple script to scroll down the page
function scrollDown() {
window.scrollBy(0,50); // horizontal and vertical scroll increments
}
scrolldelay = setTimeout('scrollDown()',100); // scrolls every 100 milliseconds
Now I wish to intercept when the user scrolls up himself to stop the setTimeout with a
clearTimeout(scrolldelay);
Any idea? Preferable with pure js
An alternative to accepted answer is here: http://jsfiddle.net/Vy8tW/
How it works: Each time the page is scrolled, it compares the current scrollTop to the previous one. If we detect that the page has been scrolled up, we stop the interval.
You can re-start the scroll by calling start() again.
Try it here: http://jsfiddle.net/fR9Wt/3/