I'm trying to play with d3 transitions - I need to do both translate and rotate. I have original coordinates:
let data = [
{x: 100, y: 100, rotation: 45},
];
and 2 rectangles. One is doing translate first, second one is doing rotation first.
This is resulting transform after drawing rectangles:
transform="rotate(45 115 105) translate(100, 100)"
transform="translate(100, 100) rotate(45 115 105)"
they have the same translate and rotate transformations, only thing which differs is order of them.
Then I change data:
data[0].x += 30;
data[0].y += 20;
data[0].rotation += 45;
and I would expect to get some transition ending up with this transformation:
transform="rotate(90 145 125) translate(130, 120)"
transform="translate(130, 120) rotate(90 145 125)"
but what I really get is this:
transform="translate(150, 110) rotate(90)"
transform="translate(400, 100) rotate(90)"
- notice it changes order of translate rotate for the first rectangle.
- it also removes the center of rotation from rotate transformation (does it somehow compute it during transition?)
- how does it get the resulting numbers?
How does the d3 transition work? I need to get some expectable result, since I'm trying to play with some more advanced transitions.
Here is simple example: https://jsfiddle.net/pp6npw4g/2 (click move to start transition)