I'm trying to animate triangle (think, needle of an angular gauge) such that it rotates at a given point (see the red dot).
var svg = Raphael("container",400,400),
triangle = svg.path("M210 200L190 200L200 100Z").attr({fill:"#000"}),
circle = svg.circle(200,200,5).attr({fill:"#f00"});
// to animate ??
triangle.animate({rotation:100,cx:200,cy:200},1000,'<>');
// doesn't work
JSFiddle Example
I can rotate (without animating) along that center fine:
// to rotate with center point 200,200, works fine
triangle.rotate(80,200,200);
But I can't for the life of me figure out how to animate the rotation such that it rotates around that point. It always seems to rotate at the center of the path.
Any help?
yourTriangle.animate({transform: "r" + 15}, 2000);
Where:
r
= rotation 15
= angle in degrees2000
= time in milliseconds.You need to specify center coordinates:yourTriangle.animate({transform: "r60" + "," + centerX + "," + centerY}, 2000);
JSFiddle example
So you have to use string as an object property: {transform: "r15"}
or {transform: "r15, centerX, centerY"}
.
Try this:
triangle.animate({rotation:"300 200 200"},1000,'<>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With