{"id":6360,"date":"2010-05-12T06:16:17","date_gmt":"2010-05-12T13:16:17","guid":{"rendered":"http:\/\/css-tricks.com\/?p=6360"},"modified":"2010-12-18T18:07:59","modified_gmt":"2010-12-19T01:07:59","slug":"circulate","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/circulate\/","title":{"rendered":"Circulate"},"content":{"rendered":"

I had the occasion come up recently where I needed to animate something in a circle. It never occurred to me until then that there wasn’t an obvious solution to this already with jQuery. So I figured out a way, and made a plugin out of it.<\/p>\n

\n\"\"<\/p>\n

This unicorn can fly friggin backwards with this plugin.<\/p>\n<\/div>\n

View Demo<\/a>   Download Files<\/a><\/p>\n

<\/p>\n

The Empowering Concepts<\/h3>\n

This is a jQuery plugin, so obviously it relies upon the jQuery<\/a> library. Specifically, jQuery 1.4 or later, because we are using the .animate() functions new ability to have per property easing<\/a>. This means we can animate the “top” value with one easing function while animating the “left” value with a different easing function. All this talk of easing… I should say that not only does this require jQuery 1.4+, it also requires the easing plugin<\/a>. Here is the idea:<\/p>\n

\"\"<\/p>\n

So if we do that four different times, flipping around the easing functions and adding\/subtracting as necessary, we can get a circle. And not just a circle really, but any ellipse defined by height and width. <\/p>\n

Features<\/h3>\n

You can declare speed, height, and width. Those are pretty obvious \/ standard \/ expected parameters for a plugin like this. There are three others though:<\/p>\n