0

I would like to add some cool UI with rotating background on mouse move, like on icloud.com, for now I got the code below

 $("#VIEW").mousemove(function(e){ var pageCoords = e.pageX + e.pageY; var max = $(document).width() + $(document).height(); var p = (pageCoords/max)*30; $('#ROTATE').css({ 'transform':'rotate(' + p + 'deg)'}); }); 

problem is, this is realtime rotate, I like to make it slow, add some delay

2 Answers 2

1

Use animate():

$('#ROTATE').animate({ 'transform':'rotate(' + p + 'deg)'}, 600); 
Sign up to request clarification or add additional context in comments.

3 Comments

seems like does not work for me, not rotating at all, with no errors
anyway thanks for advice about animate, jQueryRotate.js + $("#ROTATE").rotate({animateTo:p}) works for me.
@user840250 it could work for you if you add a prefix to the transform to make it cross browser, ex; -moz-transform, -webkit-transform, -o-transfrom and -ms-transform. you could also use jquery version prior to 1.7.2, it will add the prefixes automatically.
0

I propose you to read this http://code.google.com/p/jqueryrotate/wiki/Examples. You have many examples for rotate images. For example :

$("#img").rotate({ bind: { mouseover : function() { $(this).rotate({animateTo:180}) }, mouseout : function() { $(this).rotate({animateTo:0}) } } }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.