【发布时间】:2018-04-13 02:19:11
【问题描述】:
我在 d3 中看到了一些奇怪的行为。我以通常的方式有一个力有向图
node = svg.selectAll(".node").data(graph.nodes).enter().append("circle")....
当有人点击一个节点时,我想要一个简单的动画(而不是 console.log)
function set_focus(d) { console.log('set'); }
function remove_focus() { console.log('remove'); }
node.on("mousedown", set_focus);
node.on("mouseup", remove_focus);
有趣的是,当我在节点上按下鼠标时,set 事件会触发,但是当我释放鼠标时,remove_focus 不会触发。有人知道发生了什么吗?
d3v5、chrome 65、macOS 10.13
【问题讨论】:
-
我无法重现该问题:jsfiddle.net/wyv6syzw
-
感谢您的提琴!可能是我自己应该做的事情。我想知道我到底是怎么吞下那个事件的……你有兴趣/愿意看我的代码吗?
-
如果您可以公开分享,可能会有很多人愿意/有兴趣查看您的代码。
-
@mattbatman 该应用位于alexlenail.me/NN-SVG。代码在github.com/zfrenchee/NN-SVG。我选择将它们全部放在一个 html 文件中——希望你能原谅:]
标签: d3.js