How to preserve a node position when you nest it (add a parent node) #1202
-
Hi, In our project we have a functionality to nest nodes inside other 'special' nodes We do this by adding those keys to the node object nestedNode.parentNode = parentNode.id;
nestedNode.expandParent = true; Is there a way to preserve the position of the child node? as of now we reset the position to It be really great if there is away to preserve the relative position of the child node where it was dragged - is there a relationship/ a way to calculate the position relative to the parent workflow from the position relative to the main |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think you are needing "node.computedPosition" like "node.position" is a object with x and y but here is absolute, based on main canvas not in the parent node |
Beta Was this translation helpful? Give feedback.
Do this with computedPosition is hard because have to calculate the diff between parent and child positions, so i found a new way much simpler to preserve the child node position:
just set "node.extend" to "parent" before set the "parentNode" and remove later using nextTick, i did this in "onNodeDragStop" event