Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

continuous movement animation with jquery

continuous movement

I would like to recreate the truck moments in the above site , It is done in mootools. How would I code this, is there a jQuery plugin to do this?

So animate an object from beginning to end of screen and then it starts over again. How would I do this jQuery

Any help will e appreciated

like image 632
nokiko Avatar asked Dec 01 '22 09:12

nokiko


1 Answers

Here's a JSFiddle sample http://www.jsfiddle.net/XpAjZ/

More on jQuery animate: http://api.jquery.com/animate/

Demonstration shows 2 boxes animated across the screen at different speeds etc. (See fiddle)

Relevant jQuery Code:

var animateMe = function(targetElement, speed){

    $(targetElement).css({left:'-200px'});
    $(targetElement).animate(
        {
        'left': $(document).width() + 200
        },
        {
        duration: speed,
        complete: function(){
            animateMe(this, speed);
            }
        }
    );

};
animateMe($('#object1'), 5000);
animateMe($('#object2'), 3000);
like image 139
Jason Benson Avatar answered Dec 05 '22 15:12

Jason Benson