d-_-b
d-_-b

Reputation: 23181

jquery constant rotation

Could someone show me a simple script that rotates

<img src="xxx.jpg" id="image">

I've read Howto rotate image using jquery rotate plugin?, but I'm still having trouble getting it to work, I've also looked at http://code.google.com/p/jqueryrotate/wiki/Examples#Example_3 but can't seem to find their code...

could someone help me out?

thanks!

Upvotes: 0

Views: 3173

Answers (2)

mrtsherman
mrtsherman

Reputation: 39872

You could try just setting the rotation transform instead of relying on the plugin. This won't cover all browser types, but gets the big, modern browsers.

http://jsfiddle.net/YgBMa/1

var angle = 0;
setInterval(function() {
    console.log(angle);
    $("#image")
        .css('-webkit-transform', 'rotate('+angle+'deg)')
        .css('-moz-transform', 'rotate('+angle+'deg)')
        .css('-ms-transform', 'rotate('+angle+'deg)');
    angle++;
}, 100);

Upvotes: 2

Ansel Santosa
Ansel Santosa

Reputation: 8444

The code is right below the example...

var angle = 0;
setInterval(function(){
      angle += 3;
     $("#img").rotate(angle);
}, 50);

Upvotes: 2

Related Questions