1

What's the best way to accomplish a loop of this animation while adding an animation to go back to the top?

$(window).load(function() { $("html, body").animate({ scrollTop: $(document).height() }, 110000, function() { // Animation complete. }); }); 

Alright! With @void help. I got this working.

var x = 110000; // This is 110sec. var y = 100000; // This is 100sec. $(window).load(function() { $("html, body").animate({ scrollTop: $(document).height() }, x, function() { $("html, body").animate({ scrollTop: (0) }, y); }); setInterval(function(){ $("html, body").animate({ scrollTop: $(document).height() }, x, function() { $("html, body").animate({ scrollTop: (0) }, y); }); }, x+y); }); 

shoot. This isn't looping...

1 Answer 1

2

This is how you can loop.

 var x = 110000; // This is 110sec. var y = 100000; // This is 100sec. $(window).load(function() { $("html, body").animate({ scrollTop: $(document).height() }, x, function() { $("html, body").animate({ scrollTop: 0 }, y); }); setInterval(function(){ $("html, body").animate({ scrollTop: $(document).height() }, x, function() { $("html, body").animate({ scrollTop: 0 }, y); }); }, x+y); }); 
Sign up to request clarification or add additional context in comments.

1 Comment

Ah, yes, definitely. set the animations as variables and loop those with the interval, but what about scrolling back to the top? any ideas?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.