简体   繁体   English

如何启用和禁用鼠标悬停事件?

[英]How can I enable and disable mouseover events?

I need to enable and disable mouse over event for the rectangle created using d3.我需要为使用 d3 创建的矩形启用和禁用鼠标悬停事件。 I have added these events line below:我在下面添加了这些事件行:

d3.selectAll("rect").call(d3.drag().on("drag", (d, i, n) => {
this.dragRectangles(d, i, n);
}))                 
.on("mouseover", mouseover)
.on("mouseleave", mouseleave)
.on("mousemove", mousemove);

var mouseover = (d, i, n) => {
this.svgMouseOver(tooltip, d, i, n);
}

var mouseleave = (d, i, n) => {
this.svgMouseleave(tooltip, d, i, n);
}

var mousemove = (d, i, n) => {
this.svgMouseMove(tooltip, d, i, n);
}

I found below solution to enable or disable the mouse events我找到了以下启用或禁用鼠标事件的解决方案

//To disable the mouse event for the rectangle. //禁用矩形的鼠标事件。

d3.selectAll("rect").attr("pointer-events", "none");

//To Enable the mouse event for the rectangle. //为矩形启用鼠标事件。

d3.selectAll("rect").attr("pointer-events", "all");

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

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