简体   繁体   English

svg拖动目标整体 <object> 而不是鼠标处理程序?

[英]svg dragging targets whole <object> instead of mouse-handlers?

I have an external svg that I embed via an tag. 我有一个通过标签嵌入的外部svg。 I then use javascript to insert mouse handlers to -s in order to "rotate" them with the mouse. 然后,我使用javascript将鼠标处理程序插入到-s中,以便使用鼠标“旋转”它们。 (Just like knobs on a stereo.) (就像立体声上的旋钮一样。)

Now, every once in a while, this doesn't work. 现在,有时不起作用。 Firefox then doesn't show the drag-cursor which I told it to show but instead the crossed-out-circle cursor. Firefox然后不显示我告诉它显示的拖动光标,而是显示划圆的光标。 Also, it doesn't rotate meaning that the javascript is not run. 另外,它不会旋转,表示JavaScript未运行。 This happens roughly every third time - other times it works great. 这种情况大约每隔三次发生-有时效果很好。

To me, it looks like firefox tries to drag the whole svg-object instead of handing the mouse-events over to the javascript and let that do it's magic. 在我看来,firefox似乎试图拖动整个svg对象,而不是将鼠标事件移交给javascript并让它神奇。

Does that sound familiar to anybody? 听起来有人熟悉吗? What could I do? 我能做什么?

Cheers! 干杯!

Okay, short time after, although I had searched the web, I found the answer myself. 好吧,不久之后,尽管我已经在网上搜索了,但我自己找到了答案。

This works just like Dragging/selecting inside SVG in Firefox . 就像在Firefox中在SVG中拖动/选择一样。

Let me quote from there: 让我从那里引用:

This behaviour is described in the following bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=525591 You can fix this by calling preventDefault() on the event. 以下错误报告中描述了此行为: https ://bugzilla.mozilla.org/show_bug.cgi?id =525591您可以通过在事件上调用preventDefault()来解决此问题。 This really needs to go in an FAQ somewhere. 这确实需要在某个地方的FAQ中进行。

I have nothing to add :-) 我没有补充:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM