Merge pull request #4782 from xyflow/fix/evaluateAbsolutePosition

fixed evaluateAbsolutePosition for nested nodes
This commit is contained in:
Peter Kogo
2024-11-08 11:23:54 +01:00
committed by GitHub
2 changed files with 12 additions and 10 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@xyflow/system': patch
'@xyflow/react': patch
'@xyflow/svelte': patch
---
Fix node intersections in nested flow.
+1 -6
View File
@@ -252,19 +252,14 @@ export function evaluateAbsolutePosition(
nodeLookup: NodeLookup, nodeLookup: NodeLookup,
nodeOrigin: NodeOrigin nodeOrigin: NodeOrigin
): XYPosition { ): XYPosition {
let nextParentId: string | undefined = parentId;
const positionAbsolute = { ...position }; const positionAbsolute = { ...position };
while (nextParentId) { const parent = nodeLookup.get(parentId);
const parent = nodeLookup.get(nextParentId);
nextParentId = parent?.parentId;
if (parent) { if (parent) {
const origin = parent.origin || nodeOrigin; const origin = parent.origin || nodeOrigin;
positionAbsolute.x += parent.internals.positionAbsolute.x - (dimensions.width ?? 0) * origin[0]; positionAbsolute.x += parent.internals.positionAbsolute.x - (dimensions.width ?? 0) * origin[0];
positionAbsolute.y += parent.internals.positionAbsolute.y - (dimensions.height ?? 0) * origin[1]; positionAbsolute.y += parent.internals.positionAbsolute.y - (dimensions.height ?? 0) * origin[1];
} }
}
return positionAbsolute; return positionAbsolute;
} }