Home » Javascript » jquery auto scroll website with pause

jquery auto scroll website with pause

Posted by: admin September 18, 2018 Leave a comment


How can I set jQuery auto scroll web page and with pause / stop for a specific px and continue auto scrolling? It’s something like a user scrolling on the web page reading an article, like scroll and stop and continue scrolling something like that. I can’t seem to find a good example on the internet and all I got the answer from searching is only jQuery auto scroll example only.

If you can’t understand my question it’s something looks like this: Example from codepen

Here is my code:

$("html, body").animate({ scrollTop: $(document).height() }, 1000);

setTimeout(function() {
$('html, body').animate({scrollTop:0}, 1000); // 1000 is the duration of the animation


$("html, body").animate({ scrollTop: $(document).height() }, 500); //  Speed from Bottom to top

setTimeout(function() {
$('html, body').animate({scrollTop:0}, 5000); // Speed from Top to bottom
},500); // What is this speed refer to?

},1000); // What is this speed refer to?

By the way, I am new in jQuery, do you mind explain a little bit to me what is the meaning of both of the 500 and 1000 second meaning? I know it refers to second but what is the meaning of adding 2 of it? Thanks!