Svg, get absolute position position

I am trying to get the absolute position of a group object. In html, I have:

<svg width="1301" height="388">
  <g transform="translate(3245.914484377907,2040.9185616875811)scale(1.0)">
    <g class="node" data-toggle="popover" data-placement="bottom" transform="translate(33,50)">
      <image xlink:href="/thumb_glyphicons/commons/stack-overflow.png" x="-3014" y="-1905" width="64" height="64" transform="rotate(0 -2982,-1873)"></image>
      <text x="-2982" y="-1819" text-anchor="middle" font-size="12.8px">absolute position</text>
    </g>
  </g>
</svg>

I see that it has some attr: scale, group_main_translate_x, group_main_translate_y, node_translate_x, node_translate_y, node_x, node_y

I am trying to execute a function: abs_node_x = (node_translate_x + node_x + group_main_translate_x) * scale.

Seems correct: (-3014 + 33 + 3245.914484377907) * 1

But when scale! = 1, I have the wrong value. Sometime I get a "-value".

Plz fix calculation function help me!

abs_position

+4
source share
1 answer

-, jsFiddle , .

, . , , .

, -. Chrome , IE . , 200 , 2x, 400 Chrome 200 IE.

, .

0

Source: https://habr.com/ru/post/1547685/


All Articles