如何在从一个位置移动到另一个位置时找到svg矩形的绝对位置

如何在从一个位置移动到另一个位置时找到svg矩形的绝对位置,svg,Svg,移动时默认矩形位置为(100200),如何根据SVG宽度和高度获得绝对位置 下面的代码给出了相对路径。当我向左/向上移动时,会给出-ve值 <svg width="600" height="600"> <!-- code --> <rect class="draggable" x="100" y="200" width="80" height="80" fill="blue" transform="matrix(1 0 0 1 0 0)" onmousedown=

移动时默认矩形位置为(100200),如何根据SVG宽度和高度获得绝对位置

下面的代码给出了相对路径。当我向左/向上移动时,会给出-ve值

<svg width="600" height="600">
<!-- code  -->
<rect class="draggable" x="100" y="200" width="80" height="80" fill="blue" transform="matrix(1 0 0 1 0 0)" onmousedown="selectElement(evt)"/>
</svg>

最后,我找到了这个方法

<svg width="600" height="600">
<!-- code  -->
<rect class="draggable" width="80" height="80" fill="blue" transform="matrix(1 0 0 1 0 0)" onmousedown="selectElement(evt)"/>
</svg>

在上面的代码中,我去掉了x和y的位置,所以它完全依赖于变换矩阵e,f的绝对位置