Autoresize parent node #2821
-
Is there a way to auto-resize the parent when some child's nodes are moved to the border of the parent node? I've implemented a bunch of code that works only on width and height so I can only automatically resize my parent in two directions but I'm looking for something that can help me to have a behavior similar to NodeResize but without manually handling the size but trigger the resize when I drag a child node from inside the parent near the border. I can handle the drag stuff and calculate the current node's dragged position. I'm looking for a way to trigger the NodeResize and change the parent node's size. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You're probably looking for the {
id: '2',
data: { label: 'Group A' },
position: { x: 100, y: 100 },
className: 'light',
style: { backgroundColor: 'rgba(255, 0, 0, 0.2)', width: 200, height: 200 },
},
{
id: '2a',
data: { label: 'Node A.1' },
position: { x: 10, y: 50 },
parentNode: '2',
expandParent: true, // <-- set this to true to expand the parent when reaching it's border
}, Though be aware that there is no "auto-collapse" option to reverse the resize. |
Beta Was this translation helpful? Give feedback.
-
Follow up of this question, is there a way to check the cumulative size of all children's width/height under a parent without writing a recursive function to parse the nodes array? |
Beta Was this translation helpful? Give feedback.
-
How to achieve automatic reduction of node group size |
Beta Was this translation helpful? Give feedback.
You're probably looking for the
expandParent
option?Though be aware that there is no "auto-collapse" option to reverse the resize.