Duder-onomy / svgpan

Automatically exported from code.google.com/p/svgpan
0 stars 0 forks source link

1.2.2 broken in Firefox when using Viewport (fix included) #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
While trying to use an SVG image with a Viewport set and svgpan 1.2.2 I'm 
unable to move/zoom the SVG.

Firefox outputs lots of "matrix is undefined" errors to the console from the 
setCTM line in getRoot().  This appears to be because Firefox is behaving 
differently (to say Chrome) on the call to t.getCTM().  There is some 
discussion about the issue in a Firefox bug report at 
https://bugzilla.mozilla.org/show_bug.cgi?id=543965

As a result of that bug report I've found I can fix the issue by changing line 
115 in version 1.2.2.

From:
  setCTM(r, t.getCTM());

To:
  setCTM(r, t.getCTM() || t.getScreenCTM());

Original issue reported on code.google.com by graham_a...@hotmail.com on 30 Sep 2011 at 9:15

GoogleCodeExporter commented 9 years ago
I solved it by simply removing the block of code, since removing the viewbox 
was a bad thing in my case - the viewbox helps to center my SVG in the page.  
The result:

function getRoot(root) {
    if(svgRoot == null) {
        var r = root.getElementById("viewport") ? root.getElementById("viewport") : root.documentElement;
        svgRoot = r;
    }
    return svgRoot;
}

Original comment by rdu...@mcmillan-mcgee.com on 2 Oct 2012 at 4:46

GoogleCodeExporter commented 9 years ago
I just realized that my solution was no good - adding a viewBox attribute to 
lion.svg revealed the bugs in my approach.  Removing the viewbox seems to be 
necessary for proper operation.  Nice work Graham.

Original comment by rdu...@mcmillan-mcgee.com on 2 Oct 2012 at 6:39

GoogleCodeExporter commented 9 years ago
No problem, glad my report helped someone.  I guess this project is dead now?  
No release for over a year.

Original comment by grahamwh...@gmail.com on 3 Oct 2012 at 7:13