svgdotjs / svg.js

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

The SVG A element not move according its parent #1110

Closed amanfrinati closed 4 years ago

amanfrinati commented 4 years ago

Bug report

I need to create an SVG A element into a group element and move the group according another coordinate system, but this feature seems like not work on svg.js version 3.0.16.

Fiddle

This code running in version 2.7.0 https://jsfiddle.net/amanfrinati/oj26zm9b/9/: in this snippet, the red square was move on (200, 200) moving the granfather g1.

Here https://jsfiddle.net/amanfrinati/n953op7u/6/ the same snippet running in svg.js@3.0.16 not working.

Explanation

Fuzzyma commented 4 years ago

Good catch. <a> should behave the same as <g>. The reason it worked in 2.x is because groups got translated when you used move(). This is handled differently in 3.x. You can use the old behavior by explicitely translating the group:

grp.translate(200, 200)
amanfrinati commented 4 years ago

Ok! This solve it!

gntyu commented 3 years ago

well done!