kthornbloom kthornbloom - 1 month ago 16
jQuery Question

How to CONSTANTLY rotate an object with jquery?

OKAY! Here's the situation. I've got a jQuery plugin that's animating a background-image in my header to constantly scroll left-to-right. I have a .png of a wheel sitting on this header. I need to have the wheel constantly spinning with the moving background.

CSS3- Yes I could use CSS3, but then some poor soul using Internet Explorer would see a stationary wheel on a moving background which would be weird.

jQuery Plugins- This is what I'd LIKE to use, but I have yet to find one that will constantly rotate the image. Most only rotate by a certain angle when you activate it.

If anybody has any thoughts, I'd appreciate it!

Answer

You could try this:

http://code.google.com/p/jqueryrotate/wiki/Examples

    var rotation = function (){
   $("#img").rotate({
      angle:0, 
      animateTo:360, 
      callback: rotation,
      easing: function (x,t,b,c,d){        // t: current time, b: begInnIng value, c: change In value, d: duration
          return c*(t/d)+b;
      }
   });
}
rotation();