简体   繁体   English

在d3.js强制有向图中是否有点击和双击事件

[英]Is there a tap and double tap event in d3.js force directed graph

I am working on a force directed graph using d3.js. 我正在使用d3.js处理力导向图。 I need to handle tap and double tap event on nodes for mobile devices. 我需要在移动设备的节点上处理点击和双击事件。 Mouseover and click functions need to replicated as tap and double tap in d3.js. 鼠标悬停和点击功能需要复制为点击并双击d3.js. I have managed to get a touch event working but have no clue on how to capture double tap event in a mobile device. 我设法让触摸事件有效但却不知道如何在移动设备中捕获双击事件。

D3 has the touches event and using this you can get touch position coordinates from inside your event handler, but this doesn't give you any special handling for or help identify long press and doubletap. D3有触摸事件 ,使用它可以从事件处理程序中获取触摸位置坐标,但这并不能为您提供任何特殊处理或帮助识别长按和双击。 You can add support for long press and double tap yourself. 您可以添加长按支持并双击自己。 For long press, have a look at this example: 如需长按,请查看此示例:

Long Press in JavaScript? 长期在JavaScript?

If you're using jQuery, there are doubletap plugins like this one: 如果你正在使用jQuery,那么有像这样的双重插件:

jQuery doubletap plugin jQuery doubletap插件

Unfortunately, there is no double tap in d3, so as suggested before, you got to work with touchstart. 不幸的是,在d3中没有双击,所以如前所述,你必须使用touchstart。 Here is how 这是怎么回事

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

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