Geoorg Geoorg - 9 months ago 70
Javascript Question

SVG: GetScreenCTM() for nested SVG is different in Firefox

i have a web page with a svg which has another svg element in it. Thing is that i need to get matrix information via getScreenCTM() method (for nested svg) and firefox is returning different results than other browsers (IE, Chrome, Opera). Dont you know why is that?

Here i made a simple example:

<svg id="svgwrapper" xmlns="">
<svg id="svgnested" width="1480mm" height="297mm" viewBox="0 0 149000 29700" xmlns="">



viewBox is a transform that applies to the children of an element and not the element itself.

If Firefox worked like the other buggy browsers then you'd find it hard to position the inner <svg> element within the root <svg> element because its getScreenCTM would be different to the getScreenCTM of a path or rect say.

What you're almost certainly looking for however is the CTM of some element that's within the inner <svg> element. You'll find that the values are cross-browser consistent in that case.