I'm having an issue with snap.svg where whenever I animate a rotation between 269 and 270 degrees the whole thing spins around the entire circle instead of advancing a single degree. Here is a minimal code snippet that recreates the problem:
function testRotation() {
var draw = Snap('#test');
var box = draw.rect(0, 0, 100, 161.5);
var rotation = 268;
var increment = 1;
var transform = 't200,200r'+rotation+',50,80.75';
console.log(transform)
box.attr({
fill: '#000000',
transform: transform});
function rotate() {
if (rotation > 271) increment = -1;
if (rotation < 269) increment = 1;
rotation += increment;
var transform = 't200,200r'+rotation+',50,80.75';
console.log(rotation);
box.animate({transform: transform}, 1000);
setTimeout(rotate, 1000);
}
setTimeout(rotate, 1000)
}
Here is a JSFiddle version where you can see it in action: http://jsfiddle.net/qsmzexut/2/
It starts at 268 degrees and then every second it increases the angle by one degree. When it passes from 269 to 270 it goes all the way around. When it gets up to 272 it goes back down, then back up etc. As you can see this behavior is present in both directions.
Any way to avoid this behavior? I would love to be able to rotate a single degree and not have it swing around the entire circle! Thanks.