拉斐尔的悬停事件
我有一个带有文本的矩形对象。为此我使用了一套。我想实现一个悬停事件(即 mouseEnter 和 mouseLeave)。我的问题是,由于文本位于矩形上,因此将鼠标悬停在文本上会触发矩形的 mouseLeave 事件,因此我的悬停功能会发生折腾。我必须在代码中使用 Raphael。 有人可以建议一种方法来实现矩形的悬停,当鼠标移到内部文本中时,该悬停不会消失。
欢迎任何提示/建议
I have a rect object with a text on it. For this i have used a set. I want to implement a hover event (i.e. mouseEnter as well as mouseLeave). My problem is that since the text is on the rect hovering over the text triggers a mouseLeave event for the rect and so my hover functionality goes for a toss.It is imperative that i use Raphael in my code.
Can someone suggest a way for implemnting the hover for the rect which does not disappear when the mouse goes over in inner text.
Any hints/ suggestions are welcome
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果文本不需要某些特殊功能,则只需将鼠标悬停在集合上,而不是直接放在矩形上
if the text is not requiring some special functionality, then just put the hover on the set and not directly on the rect
我建议使悬停退出代码使用
setTimeout
并将值保存到变量中,然后对集合的所有成员使用相同的悬停进入/退出函数。在悬停输入中,检查变量是否已设置以及是否已取消。这样,如果鼠标从集合中的一个成员移动到另一个成员,则会调用悬停退出(对功能进行排队),然后调用相同的悬停输入,从而禁用退出代码。如果鼠标完全移出集合,那么计时器就会启动,一切都会按预期进行。I'd suggest making the hover exit code use
setTimeout
and save the value to a variable, and then using the same hover enter/exit function for all members of the set. In the hover enter, check if the variable is set and if it is cancel it. That way if the mouse moves from one member of the set to the other then the hover exit gets called (queuing up the functionality) and then the same hover enter gets called, disabling the exit code. If the mouse moves entirely off the set, then the timer fires and everything works as intended.