[英]D3 multiple drag handlers
Is it possible to have more than one element with a .call(drag)
on it in a force graph?在力图中是否可以有多个带有.call(drag)
的元素?
In my example I have <circle/>
s and <rect/>
s.在我的示例中,我有<circle/>
s 和<rect/>
s。 The <circle/>
s are part of my force simulation and the <rect/>
s are not. <circle/>
是我的力模拟的一部分,而<rect/>
不是。 I would like to be able to drag both of them, using separate drag handlers of course.我希望能够拖动它们,当然是使用单独的拖动处理程序。 The <circle/>
s are draggable but the <rect/>
s are not. <circle/>
是可拖动的,但<rect/>
不是。 According to some examples I've found it seems totally possible to have a drag event that is not part of a force simulation.根据一些示例,我发现似乎完全有可能发生不属于力模拟的拖动事件。 But I have no evidence of them working in tandem.但我没有证据表明它们协同工作。
Related fiddle:相关小提琴:
The circular nodes are draggable but the squares in the top left of the graph are not.圆形节点是可拖动的,但图形左上角的正方形不是。 How can I make both of them draggable?我怎样才能使它们都可拖动? I do not want the squares as part of the simulation as I do not want the forces applied to them.我不希望将正方形作为模拟的一部分,因为我不希望对它们施加力。
https://jsfiddle.net/jrymer/ftv94rzk/53/ https://jsfiddle.net/jrymer/ftv94rzk/53/
Seems even though the simulation
does not use the data
, I still need to respect the simulation
's internal timer and use it's tick
function to reposition as I drag.似乎即使simulation
不使用data
,我仍然需要尊重simulation
的内部计时器并使用它的tick
function 在我拖动时重新定位。 I have update the original fiddle to reflect this.我已经更新了原来的小提琴来反映这一点。 The rectangles I added do not effect the nodes force wise, but can still be dragged, which was my goal.我添加的矩形不会影响节点力,但仍然可以拖动,这是我的目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.