Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag event for nodes in Cytoscape.js

I'm looking for an event that fires as a node is being dragged. I thought that tapdrag looked like what I wanted, but tapdrag fires whenever the mouse moves over the node only when the mouse button is not down (so the node's not being dragged, basically mouseover). I've tried several other events, but none seem to do what I need.

How can I fire an event as a node is being dragged? Specifically, I want to move another node while the first is being dragged, which I'd rather do without using a compound node.

like image 734
TonyM Avatar asked Oct 28 '25 06:10

TonyM


1 Answers

Use the drag event.

The events are all listed and documented: http://js.cytoscape.org/#events/collection-events

You can manually .position() on the second node when the drag happens on the first node.

To set rules for node placement, like moving two nodes in lockstep, use the automove extension: https://github.com/cytoscape/cytoscape.js-automove

like image 160
maxkfranz Avatar answered Oct 29 '25 23:10

maxkfranz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!