Skip to content Skip to sidebar Skip to footer

Continuous Scrolling Page Using Javascript

I am trying to repeat an animation where a page automatically scrolls to the bottom. When it reaches the bottom I want it to then scroll to the top. Then, repeat forever. Howeve

Solution 1:

This should do it: http://jsfiddle.net/John_C/8ZfKr/

var scrollDirection = 1;
function pageScroll() {
    window.scrollBy(0,scrollDirection); // horizontal and vertical scroll increments
    scrolldelay = setTimeout('pageScroll()',50); // scrolls every 50 milliseconds
    if ( (window.scrollY === 0) || (window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
        scrollDirection = -1*scrollDirection;
    }
}
pageScroll();

Post a Comment for "Continuous Scrolling Page Using Javascript"