svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
10.95k stars 1.07k forks source link

Rotating a polygon inside a group affects position of sibling circle of the group #1275

Closed alexNecroJack closed 10 months ago

alexNecroJack commented 2 years ago

Fiddle

https://jsfiddle.net/1b578zjg/

Explanation

In the fiddle, if you enable the line before the last one, the bag disappears. This happens either by removing the "rotate" which is on the polygon, or by removing the "move(0,0)" which is on the parent group. Note here, that rotate should have nothing to do with it. Polygon belongs to a subgroup, while the circle being affected belongs to the parent group of the group which actually has the polygon.

alexNecroJack commented 2 years ago

image

Fuzzyma commented 2 years ago

Groups dont have a dimension on their own. They are as big as their content. If you rotate the polygon, you are changing the dimension of the group.The rototated polygon takes up more space so that its outer edge is higher than the circles border.

Calling move(0,0) is moving the group so that its bounding box (the dimension inherited by its children) will be a 0,0. So this code is working exactly as expected