continuous movement animation with jquery

前端 未结 4 1890
南旧
南旧 2020-12-24 11:38

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

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 11:46

    If you have a div with a picture inside, like this:

    Here is an jQuery example to slide the picture over the div/screen:

    function moveTruck(){
        $('#truck').animate(
            {'margin-left': '1000px'}, 
            3000, // Animation-duration
            function(){
                $('#truck').css('margin-left','-100px');
                moveTruck();
            });
        }
    
    moveTruck();
    

    Hope that works out...

提交回复
热议问题