Created attachment 8672336 [details] bug.htm User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0 Build ID: 20150929144111 Steps to reproduce: See this svg: <svg height="200px" width="200px" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg"> <defs id="SvgjsDefs1005"></defs> <svg viewBox="50 50 1000 1000" id="nested"></svg> </svg> call getCTM() on nested SVG: `document.getElementById('nested').getCTM()` File with "working" example attached Actual results: The result of getCTM() is an identity matrix Expected results: The result should take the viewBox into account. e.g. chrome returns a: 0.2 b: 0 c: 0 d: 0.2 e: -10 f: -10
viewBox is a transform applied to an element's children.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → INVALID
@Robert Longson If you apply the transformation only to the elements and not to the svg itself the following scenario will not work: - move the visual representation of an element from one nested svg to another (both witth viewport) In order to accomplish that in a normal way you would get the ctm of the element and multiply it with the ctm of the parent element. You then would set the new matrix as transformation of the element you want to move. This way the element remains its visual representation accross different places. This works for groups since their transformation is taken into account in their ctm. Same should be true for nested svg.
If you don't do it this way you won't know where to place the <svg> element itself as its own co-ordinates would be affected by the viewBox. If you want the co-ordinate system the children are in, put a child element in and get the ctm of that.
This makes the ctm much less useful for so many cases but what you say is true. It would lead to other unexpected behavior. However placing an element into the svg only to get the matrix seems not to be a valid way. Somewhat like a getCoordinateCTM-should be implemented for this case...
I noted that the screenCTM has all viewbox and transformations included. I will take this one. Can be closed
You need to log in before you can comment on or make changes to this bug.