From a8d590a60be23437e1d0a87a5d7a6f6ba9d86be9 Mon Sep 17 00:00:00 2001 From: moklick Date: Fri, 25 Nov 2022 21:25:00 +0100 Subject: [PATCH] chore(nodeOriginHelper): cleanup --- packages/core/src/utils/graph.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/core/src/utils/graph.ts b/packages/core/src/utils/graph.ts index f07267a5..ea390967 100644 --- a/packages/core/src/utils/graph.ts +++ b/packages/core/src/utils/graph.ts @@ -156,19 +156,18 @@ export const getNodePositionWithOrigin = ( }; } - const position: XYPosition = { - x: node.position.x - (node.width ?? 0) * nodeOrigin[0], - y: node.position.y - (node.height ?? 0) * nodeOrigin[1], - }; - - const positionAbsolute: XYPosition = { - x: (node.positionAbsolute?.x ?? 0) - (node.width ?? 0) * nodeOrigin[0], - y: (node.positionAbsolute?.y ?? 0) - (node.height ?? 0) * nodeOrigin[1], + const offset: XYPosition = { + x: (node.width ?? 0) * nodeOrigin[0], + y: (node.height ?? 0) * nodeOrigin[1], }; return { - ...position, - positionAbsolute, + x: node.position.x - offset.x, + y: node.position.y - offset.y, + positionAbsolute: { + x: (node.positionAbsolute?.x ?? 0) - offset.x, + y: (node.positionAbsolute?.y ?? 0) - offset.y, + }, }; };