refactor(node): make expandParent compatible with extent parent

This commit is contained in:
moklick
2023-09-26 15:55:21 +02:00
parent 9865b9c2bf
commit 88104fc15f
3 changed files with 4 additions and 2 deletions

View File

@@ -81,6 +81,7 @@ export type NodeDragItem = {
parentNode?: string;
dragging?: boolean;
origin?: NodeOrigin;
expandParent?: boolean;
};
export type NodeOrigin = [number, number];

View File

@@ -227,7 +227,7 @@ export function calcNextPosition<NodeType extends NodeBase>(
: parentPos;
}
if (node.extent === 'parent') {
if (node.extent === 'parent' && !node.expandParent) {
if (node.parentNode && node.width && node.height) {
const currNodeOrigin = node.origin || nodeOrigin;
@@ -245,7 +245,7 @@ export function calcNextPosition<NodeType extends NodeBase>(
onError?.('005', errorMessages['error005']());
currentExtent = clampedNodeExtent;
}
} else if (node.extent && node.parentNode) {
} else if (node.extent && node.parentNode && node.extent !== 'parent') {
currentExtent = [
[node.extent[0][0] + parentPos.x, node.extent[0][1] + parentPos.y],
[node.extent[1][0] + parentPos.x, node.extent[1][1] + parentPos.y],

View File

@@ -65,6 +65,7 @@ export function getDragItems<NodeType extends NodeBase>(
width: n.width,
height: n.height,
origin: n.origin,
expandParent: n.expandParent,
}));
}