SVG-Edit / svgedit

Powerful SVG-Editor for your browser
MIT License
6.33k stars 1.52k forks source link

use element position error #974

Open w8w8w8 opened 1 month ago

w8w8w8 commented 1 month ago

Load the svg file ,and click some element , the select element postion error

the svg file :
243

w8w8w8 commented 1 month ago

https://github.com/SVG-Edit/svgedit/assets/4744039/5e76f492-1568-4884-96b4-592963ad2f26

jfhenon commented 1 month ago

I think it is an issue with the "symbol" tag. Can you make a very simple SVG in which the problem occurs?

jfhenon commented 1 month ago

such as this one:

<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <!-- Created with SVG-edit - https://github.com/SVG-Edit/svgedit-->
 <defs>
  <symbol id="svg243_76" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
   <rect fill="#FF0000" height="500" id="svg_1" stroke-width="5" width="500" x="0" y="0"/>
  </symbol>
 </defs>
 <g class="layer">
  <title>Layer 1</title>
  <use id="svg243_77" transform="rotate(-90 200 200) matrix(0.1 0 0 0.1 0 0)" x="200" xlink:href="#svg243_76" y="200"/>
 </g>
</svg>
jfhenon commented 3 weeks ago

I could find a quite simple shape on which the bug occurs. I also tested that this bug unfortunately is also with older version of svgedit (I tested with 5.1 and 3.2).

<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - https://github.com/SVG-Edit/svgedit-->
<g class="layer">
<title>Layer 1</title>
<rect fill="#FF0000" height="50" id="svg_2" stroke-width="5" transform="rotate(-45) matrix(0.1 0 0 1 0 0)" width="50" x="100" y="100"/>
</g>
</svg>

I believe this is an issue in svgcanvas in the function recalculateDimensions() of recalculate.js

May not be very easy to fix...all PRs on this subject are very welcome..