Re: getTransformToElement: Include nested SVG's x/y attributes?

<svg id="svg" xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg">  <svg id="inner" x="1" y="0">
<rect id="r2" x="2" y="0"/>  </svg>  <rect id="r" x="1" y="0"/>
<foreignObject id="fo" x="1" y="0">
  </foreignObject>
</svg>

Given the markup above inner, r and fo should surely return the same
results both for getTransformToElement from the root SVG and for
getScreenCTM.
In all cases this should be the identity transform. It's pretty clear
this is the only interpretation that makes sense for rendered elements
such as rect, circle, etc
particularly as most of them don't actually have x, y attributes. I
think only Firefox works this way for svg and foreignObject elements
currently though which is unfortunate.

So x, y (when they exist) must be interpreted as the position of the
element within the co-ordinate system established by the element's
transform (if it has one).

The x and y (and viewBox) form additional transforms that apply to the
children of the element if it is a container element.

So if you want to know where to place a rect inside inner for
instance, create it, attach it in the right place in the DOM and then
ask the transform or screenCTM for that newly created element.

Robert.

Received on Monday, 15 September 2014 12:26:26 UTC