在d3.js强制有向图中有一个水龙头和双击事件 [英] Is there a tap and double tap event in d3.js force directed graph

查看:340
本文介绍了在d3.js强制有向图中有一个水龙头和双击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用d3.js工作在一个力有向图。我需要处理在移动设备的节点上的点击和双击事件。鼠标悬停和点击功能需要在d3.js中作为点击和双击进行复制。我已经设法获得触摸事件的工作,但没有线索如何捕获在移动设备中的双击事件。

I am working on a force directed graph using 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. 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有触摸事件,使用它可以获得触摸位置坐标在你的事件处理程序内,但这不给你任何特殊的处理或帮助识别长按和双击。您可以添加支持长按和双击自己。对于长按,请查看此示例:

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. You can add support for long press and double tap yourself. For long press, have a look at this example:

Long Press in JavaScript?

如果您使用jQuery,则有如下的doubletap插件:

If you're using jQuery, there are doubletap plugins like this one:

jQuery doubletap plugin

这篇关于在d3.js强制有向图中有一个水龙头和双击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆