child nodes get repositioned correctly when resizing top or left

This commit is contained in:
peterkogo
2024-01-23 12:35:24 +01:00
parent 8a9f8127b5
commit abc6fea20b
5 changed files with 111 additions and 7 deletions
@@ -7,7 +7,8 @@
ResizeControlVariant,
type ControlPosition,
type XYResizerInstance,
type XYResizerChange
type XYResizerChange,
type XYResizerChildChange
} from '@xyflow/system';
import type { ResizeControlProps } from './types';
@@ -66,7 +67,7 @@
snapToGrid: !!$snapGrid
};
},
onChange: (change: XYResizerChange) => {
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
const node = $nodeLookup.get(id);
if (node) {
node.height = change.isHeightChange ? change.height : node.height;
@@ -76,6 +77,13 @@
? { x: change.x, y: change.y }
: node.position;
childChanges.forEach((childChange) => {
const childNode = $nodeLookup.get(childChange.id);
if (childNode) {
childNode.position = childChange.position;
}
});
$nodes = $nodes;
}
}