Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RaphaelJS rotation not working

I'm banging my head against a wall with this one. I have raphael js version 2.0 and I need to make images rotate in a way that's cross-browser. I would love to do it in CSS3, but not all browsers support what I need to do.

so, after racking my brain, I went to the Raphael playground and tried out some code in there. Doesn't work there either. What's going on here?

go to playground: http://raphaeljs.com/playground.html run this code, should see an outline of a square. paper.rect(100, 100, 300,300).animate({rotation:"-45"}, 2000);

using transform works:

paper.rect(100, 100, 300,300).animate({transform:"r45"}, 2000);

but unfortunately with transform, I can't seem to specify a centerpoint. I want the object to rotate off the bottom-left corner. I can do that with this code:

paper.rect(100, 100, 300,300).rotate(45,0,300)

but that doesn't animate, or accept easing, or have any callbacks.

I've seen "rotation" in several examples including these:

http://www.irunmywebsite.com/raphael/additionalhelp.php#PAGETOP http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/

thanks, - keith

like image 569
keith73 Avatar asked Oct 26 '11 20:10

keith73


1 Answers

Going to the playground site and pasting this code:

paper.rect(100, 100, 300,300).animate({transform:"r-45,0,0"}, 2000);

rotates the rectangle from the absolute 0,0 position. See raphael js code @ github, which shows that transform can either take 2 or 4 parameters for to achieve a rotation.

like image 153
topek Avatar answered Sep 28 '22 13:09

topek