在d3节点上应用phonejs的dxhold / touch事件

时间:2014-03-18 05:56:24

标签: d3.js phonejs

使用 phonejs 制作移动应用程序,我正在使用强力布局 d3.js 。我希望在 d3 的节点被双击或按住时添加一些功能。 但双击事件在手机中没有任何作用。我也尝试过jQuery touch事件,但在这里没有用。 如何将触摸事件放在 d3 的节点上?

这是节点:

node = container.append("g").selectAll("image.node")
      .data(nodes_edges_json.nodes)
      .enter().appent("g").append("svg:image")
      .attr("class", "node")
      .attr("xlink:href", function(nodeObj) { return setImage(nodeObj); })
      .attr("width", function(nodeObj) { return setHeightWidth(nodeObj); })
      .attr("height", function(nodeObj) { return setHeightWidth(nodeObj); })
      .on("dblclick", function(data, index) {
           d3.event.preventDefault();
           getdata(data, index);
       });

1 个答案:

答案 0 :(得分:0)

我建议您调查http://eightmedia.github.io/hammer.js/我有同样的问题,不得不反对使用dxhold选项。哈默虽然工作得很好。