Hello.

We use the plugin https://github.com/timmywil/jquery.panzoom and svg.js.

It is necessary to obtain the coordinates of the mouse cursor on svg. There is a solution that works only in Chrome, but does not work in Firefox and ie. I know that there is a problem with focal point when getting the getScreenCTM () matrix.

Has anyone encountered this problem?

Update

event - the cursor event

function getCoordinates(event){ var svg = $("svg")[0]; var screen = svg.getScreenCTM().inverse(); var pt = svg.createSVGPoint(); pt.x = event.clientX; pt.y = event.clientY; var point = pt.matrixTransform(screen); var matrix = panzoomContainer.panzoom("getMatrix"); return { x: point.x * (1 / matrix[0]), y: point.y * (1 / matrix[3]) }; } 
  • Only works in chrome [this solution] [1]? [1]: jsfiddle.net/timmywil/Vu8nA - MasterAlex
  • event - cursor event function getCoordinates (event) {var svg = $ ("svg") [0]; var screen = svg.getScreenCTM (). inverse (); var pt = svg.createSVGPoint (); pt.x = event.clientX; pt.y = event.clientY; var point = pt.matrixTransform (screen); var matrix = panzoomContainer.panzoom ("getMatrix"); return {x: point.x * (1 / matrix [0]), y: point.y * (1 / matrix [3])}; } - Artur Makvetsyan

0