score:1

Accepted answer

I guess that could be done if I call the zoom.translateBy and zoom.scaleBy

Both of these are relative, i.e. they are added to / multiplied by the current transform, they don't set it. So if the current scale was 0.5 and you use scaleBy with a value of 1.0, you would still get a scale of 0.5 (because 0.5 * 1.0 == 0.5).

To "sync" the absolute values between two zooms you would instead use zoom.translateTo and zoom.scaleTo respectively.

Instead of setting the individual components of the zoom transform, a more direct approach would be to set the whole transform. For this you would use zoomTransform on the source node (or use the event.transform of a zoom event) to get the current transform and then set that transform on the target with zoom.transform.


Related Query

More Query from same tag