Motyar

Jquery Animate in Circular Path

Animations on web pages are no more with flash, We are now doing all that things with JavaScript(Jquery animate). As you know we can animate an element in custom paths with the path plugin. Today we will learn How to animate an element in circular path or over a circle using Jquery.

Idea

The jquery path plugin for animation supports custom paths like Arcs, Curves etc. Here in this post i am trying to code a curve like circle.

Code

JavaScript(Jquery)

$("#element").click(
 function(){
           $("#element").animate({
             path : new $.path.arc({
                   center : [200,200],
                   radius : 150,
                   start : 0,
                   end     : -360 * 40,
                   dir : -1
               })
        },40000);
});


Here in this code element is your target element to animate, you can customize the center, radius, start, end and direction.
Do not forget to include path plug-in.

DEMO

You can see the working demo here.

Labels: , ,

By :

7 comments

#

Anonymous Anonymous says…

Awesome tutorial! I was wondering, how would you make the object on the circular path go at a constant speed from start to finish, rather than slowly speeding up?
 
#

Blogger phoenixmajor says…

Motyar+ Im trying to figure out a way to animate a logo in with a draw on effect. Do you think its possible Jquery or HTML5/CSS3?
 
#

Blogger Reuben Lara says…

awesome plugin... trying to get an oval path so I can orbit a shape . can't figure out the best way to do it!
 
#

Blogger Motyar D says…

@Rueben check http://motyar.blogspot.com/2010/04/jquery-animate-with-custom-paths.html
 
#

Blogger Social Blogsite says…

Is there any way to access the current angle property calculated by that function?
When one animation is "stopped" by another one, to make it more responsive, I need it to start the next one from where the previous was interrupted.
Thanks.
 
#

Blogger Yusuf al Asad says…

how to make the object move circulary with constant speed? i mean the object start, move, and stop with same speed
 

Post a Comment