smooth auto scroll by using javascript

It’s not smooth because you’ve got the scroll incrementing by 50 every 100 milliseconds.

change this and the amount you are scrolling by to a smaller number to have the function run with the illusion of being much more ‘smooth’.

turn down the speed amount to make this faster or slower.

function pageScroll() {
    window.scrollBy(0,1);
    scrolldelay = setTimeout(pageScroll,10);
}

will appear to be much smoother, try it 😉

Leave a Comment