Skip to content

Drag children into parent node #1501

Answered by bcakmakoglu
yonjukyu asked this question in Q&A
Discussion options

You must be logged in to vote

the child node teleport somewhere randomly when i set his "parentNode" property to the parent id.

It doesn't teleport somewhere randomly.
When you set parentNode the relation of a nodes position changes from the viewport to the node specified as the parent.
That means x: 0, y: 0 on a "regular" node (no parent id) is the top-left corner of the viewport (given that it has not been changed from it's initial position) and the same position for a child node (with parent id) is the top-left corner of the parent node.

You will have to consider the parents position initially when trying to move a node "inside" of a parent otherwise it seems like the node is going somewhere "randomly".

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yonjukyu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants