Looking through the other posts about Snap.svg, I am not seeing much explanation regarding simple use of the animate function.
I can't quite understand the documentation and current examples of using
element.animate
.
I see that there are specific things that can be done (transform, rotate).. but what if I would like to just move something on a simple 2D axis?
Here is my current code snippet:
var s = Snap("#elevBox");
var elev1 = s.select("#elev1");
if(toggleColor == 0){
elev1.animate({
//transform: 'translate(-30,100)',
transform: "r5,200,200",
fill: "lightgreen"
}, 1000);
toggleColor = 1;
}else {
elev1.animate({
//transform: 'translate(0,0)',
transform: "r5,100,100",
fill: "red"
}, 1000);
toggleColor = 0;
}
I have toggleColor
linked to clicking a button so I toggle between the two conditions in the if-else
statement.
Can someone please advise me on how I can modify the attributes in transform to move left -> right or up -> down?
If there is any more information that would be helpful for me to provide, let me know. Thanks.