html - Jquery to animate infinite times -
i have background image hills, clouds , sun. idea animate background keep on going right left.
jquery:
$('#cloud-01').animate({backgroundposition: '(-500px -80px)'}, 40000); $('#cloud-02').animate({backgroundposition: '(-625px -30px)'}, 40000); $('#mountains-03').animate({backgroundposition: '(-2500px 50px)'}, 40000); $('#ground').animate({backgroundposition: '(-5000px bottom)'}, 40000);
this working correctly, animating 40s(time given). after stops. need give continuous moving effect.
i dont know how repeat animation once completed. can me in this.
thanks in advance.
you can use javascript setinterval function repeating animation...
var animationref=setinterval(40,function(){ /*call if animation if completed*/ if ($(":animated").length === 0) { animatebackground(); } } ); var animatebackground =function(){ $('#cloud-01').animate({backgroundposition: '(-500px -80px)'}, 40000); $('#cloud-02').animate({backgroundposition: '(-625px -30px)'}, 40000); $('#mountains-03').animate({backgroundposition: '(-2500px 50px)'}, 40000); $('#ground').animate({backgroundposition: '(-5000px bottom)'}, 40000); }
Comments
Post a Comment