I render a small graph using cytoscape.js 2.2.4 and the arbor layout.
When I do the layout a second time with one or more nodes selected, the selected ones are fixed and do not move.
You can see what I mean in the Arbor section of the cytoscape.js docs:
- click 'Run code' to apply the arbor layout to the example graph once
- select a node and click 'Run code' again, the selected node is fixed and does not move
I checked with cy.nodes(":locked")
for locked nodes but the selection is not locked. Arbor.js has a 'fixed' property for nodes, but I can't see where cytoscape.js sets this property.
Is it possible to have the seleted node move when applying the arbor layout? Can I pass the fixed: false
node property to arbor.js?
I use this to add something to the graph when clicking a node. I add some more nodes/edges and start the layout again. If the clicked node is fixed, the layout is messed up.
Update 1
I figured out that it isn't effected by the locked
state of the node but rather grabbable
. When I run cy.nodes().ungrabify()
just before the layout, the clicked node is not fixed.
When I do cy.nodes().grabify()
in the stop callback of the layout or with a long setTimeout()
after the layout, the nodes become grabbable again.
But when I then click another node and start the layout again, the node stays grabbed (as in console.log(cy.nodes(":grabbed"))
) even though cy.nodes().ungrabify()
is called.
This looks like the grabbable/ungrabbable properties are overridden somewhere. Cytoscape.js itself uses ungrabify()
and grabify()
within the arbor layout function, but this doesn't have an effect.
How can I ungrabify()
and grabify()
the nodes?