Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Svg viewbox没有';t在Firefox中使用嵌套svg返回正确的鼠标点_Svg - Fatal编程技术网

Svg viewbox没有';t在Firefox中使用嵌套svg返回正确的鼠标点

Svg viewbox没有';t在Firefox中使用嵌套svg返回正确的鼠标点,svg,Svg,当我尝试获取鼠标位置时,FirefoxV25没有什么问题。 当我使用2个svg嵌套时,FF没有返回正确的位置,但在Chrome和IE10中工作良好 这是一个例子: 啊,但是Firefox确实给出了正确的位置,其他浏览器和你的算法才是问题所在。这是问题线 svgPoint = svgPoint.matrixTransform(svgElement.getScreenCTM().inverse()); svgElement与svgPoint处于不同的坐标系中,因为svgElement有一个vie

当我尝试获取鼠标位置时,FirefoxV25没有什么问题。 当我使用2个svg嵌套时,FF没有返回正确的位置,但在Chrome和IE10中工作良好

这是一个例子:


啊,但是Firefox确实给出了正确的位置,其他浏览器和你的算法才是问题所在。这是问题线

svgPoint = svgPoint.matrixTransform(svgElement.getScreenCTM().inverse());
svgElement与svgPoint处于不同的坐标系中,因为svgElement有一个viewBox,不幸的是IE和Chrome不符合此处的SVG规范,这导致了很多混乱

你可以写下这句话,而不是上面的那一行

svgPoint = svgPoint.matrixTransform(followRectElement.getScreenCTM().inverse());
由于下面的矩形元素位于所需的坐标系中,因此该解决方案可以跨浏览器工作

svgPoint = svgPoint.matrixTransform(svgElement.getScreenCTM().inverse());
svgPoint = svgPoint.matrixTransform(followRectElement.getScreenCTM().inverse());