问题
When I add a position property on a node, it is ignored unless I also specify locked: true. I would like to specify initial positions on some nodes, yet still allow the user to move those nodes around.
Related (I think) - is there a way to let Cytoscape use a layout to determine node positions, then do a second pass and change them for any nodes that have a position property specified? It would also work to have the layout ignore or not process any nodes that have positions specified. That's what currently happens when I have locked set to true, but I'd like for it to happen if I have locked set to false on a node.
Perhaps another solution would be, how can I manually alter the positions after the layout is finished rendering?
回答1:
Don't run a layout on nodes you don't want moved. Note that you have a layout specified in the init options.
Use preset at init, and make your own explicit cy.layout() and/or eles.layout() calls. (The preset layout acts pretty much like a nop if all you specify is { name: 'preset' }
.)
Or keep your existing workflow and just unlock the nodes when the layout is done.
来源:https://stackoverflow.com/questions/41005224/cytoscape-position-ignored-if-locked-false