dom – Click事件在SVG中路径的mark-end上不起作用

前端之家收集整理的这篇文章主要介绍了dom – Click事件在SVG中路径的mark-end上不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在SVG中创建一个简单路径,并使用mark-end属性创建箭头线.然后我将click事件绑定到路径.

我发现单击标记区域时未触发click事件.如何解决这个问题?

解决方法

根据规范,这应该被认为是给定的.

07000

[…]

The rendering effect of a marker is as if the contents of the referenced ‘marker’ element were deeply cloned into a separate non-exposed DOM tree for each instance of the marker. Because the cloned DOM tree is non-exposed,the SVG DOM does not show the cloned instance of the marker.

当指针事件发生时,将通过遍历SVG的DOM树来执行命中测试,从而省略任何未暴露的阴影DOM树.这就是为什么标记实例不可能成为指针事件的目标的原因.

为了澄清,可能有趣的是,在通过CSS规则设置标记实例时也是如此,这是不可行的.只有原始标记元素,即声明<标记>元素,可以使用CSS进行样式化,而通过属性marker-start,marker-mid或marker-end引用的克隆实例不可访问,因此不能单独设置样式.

CSS2 selectors can be applied to the original (i.e.,referenced) elements because they are part of the formal document structure. CSS2 selectors cannot be applied to the (conceptually) cloned DOM tree because its contents are not part of the formal document structure.

原文链接:https://www.f2er.com/html/231674.html

猜你在找的HTML相关文章