I need to build a page that is scrolling up and down after x seconds. I just need to know how to start the second setInterval after a delay. Or if people got other solutions i’m open for anything!
here is the code:
setInterval(function() {
scrollDown();
},8000);
setInterval(function() {
scrollUp();
},8000);
function scrollDown() {
$('html, body').animate({
scrollTop: $("#page2").offset().top
}, 2000);
}
function scrollUp() {
$('html, body').animate({
scrollTop: $("#page1").offset().top
}, 2000);
}
Cleaner and more precise to do this with just one timer like so: