aleofreddi/svgpan

matrix undefined

Closed this issue · 7 comments

What steps will reproduce the problem?
1. SVG that worked perfectly in 1.2.1 now broken, says matrix is undefined, 
which I think comes from the differences in the getCTM() usage.


What is the expected output? What do you see instead?
Throws error, no JS functionality at all.

What version of the product are you using? On what operating system?
Previously SVG pan 1.2.1, in firefox 5, win xp

Please provide any additional information below.


Original issue reported on code.google.com by maschw...@gmail.com on 4 Aug 2011 at 4:21

Can you test the trunk version from svn repository?

Original comment by andrea.l...@gmail.com on 11 Aug 2011 at 8:07

  • Added labels: ****
  • Removed labels: ****
Nice library!

Same issue.  Maybe I have some more info.  It occurs if the top g element has
a viewBox property.  If I delete this property, the library functions fine,
but I would like to have this property to make the graph initially scale to
the enclosing <object> tag.  The problem is that t.getCTM() in getRoot()
returns null.  If I make setCTM(r, t.getCTM()) conditional, the graph opens
nicely scaled, but rescales to default geometry when the mouse enters the
object.

Version: SVGPan 1.2.2.  Compared to SVN seems only white-space differences.
Browser: Firefox 12.0 (Ubuntu 12.04)

Original comment by JanWiele...@gmail.com on 5 Jun 2012 at 8:44

  • Added labels: ****
  • Removed labels: ****
Same problem here. I can confirm that removing the viewBox from the outermost 
element seems to fix the problem, but is unacceptable since this viewBox is 
highly useful in proper initial scaling. In my case the outermost tag was an 
svg tag with a viewBox, not a g tag as posted in comment 2.

Original comment by kenc3...@gmail.com on 14 Nov 2012 at 9:09

  • Added labels: ****
  • Removed labels: ****
Hello i have solved the problem i think,

in "getRoot()" function, replace "setCTM(r, t.getCTM());" by "setCTM(r, 
r.getCTM());"
one letter make the difference !

Now work in Mozilla Firefox and chrome !

Original comment by bouhnosa...@gmail.com on 6 Dec 2012 at 9:04

  • Added labels: ****
  • Removed labels: ****
Thanks @bouhnosaure, the fix indeed seems to work!
Just replace t.getCTM with r.getCTM.

Original comment by rustam...@gmail.com on 21 Apr 2013 at 8:28

  • Added labels: ****
  • Removed labels: ****
[deleted comment]
To correct a bug in Firefox, if it's inside another element (e.g: <div>) or an 
<svg> in the middle of the page.

In your script to use the library:
var root = document.querySelector('svg');
setupHandlers(root);
/* be careful to root scope to run setupHandlers()*/

Delete:
var root = document.documentElement;
/*eventually setupHandlers(root) if not global scope*/

Edit:
/* replacing "window" with "root" if you want to interact only when above the 
element*/
    if(navigator.userAgent.toLowerCase().indexOf('webkit') >= 0)
root.addEventListener('mousewheel', handleMouseWheel, false); // Chrome/Safari
    else
root.addEventListener('DOMMouseScroll', handleMouseWheel, false); // Others

/* and getting a relative position for the fired event:*/
function getEventPoint(evt) {
    var p = root.createSVGPoint();
    p.x = evt.offsetX==undefined?evt.layerX:evt.offsetX;
    p.y = evt.offsetY==undefined?evt.layerY:evt.offsetY

    return p;
}

Original comment by qu.gir...@gmail.com on 29 Jan 2015 at 10:48

  • Added labels: ****
  • Removed labels: ****