From 6cc69608956cd987ba86b29685a8447f9dd12d5d Mon Sep 17 00:00:00 2001 From: moklick Date: Thu, 27 Jun 2024 12:33:54 +0200 Subject: [PATCH] refactor(xyhandle): use center for to-xy, block updates only if valid --- packages/system/src/xyhandle/XYHandle.ts | 2 ++ packages/system/src/xyhandle/utils.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/system/src/xyhandle/XYHandle.ts b/packages/system/src/xyhandle/XYHandle.ts index cc6fddba..7244d8d3 100644 --- a/packages/system/src/xyhandle/XYHandle.ts +++ b/packages/system/src/xyhandle/XYHandle.ts @@ -161,6 +161,8 @@ function onPointerDown( // we don't want to trigger an update when the connection // is snapped to the same handle as before if ( + isValid && + closestHandle && previousConnection.toHandle && newConnection.toHandle && previousConnection.toHandle.nodeId === newConnection.toHandle.nodeId && diff --git a/packages/system/src/xyhandle/utils.ts b/packages/system/src/xyhandle/utils.ts index af81c84a..409d148c 100644 --- a/packages/system/src/xyhandle/utils.ts +++ b/packages/system/src/xyhandle/utils.ts @@ -21,7 +21,7 @@ function getHandles( if (node.id === currentHandle.nodeId && type === currentHandle.handleType && handle.id === currentHandle.handleId) { excludedHandle = handle; } else { - const handleXY = getHandlePosition(node, handle); + const handleXY = getHandlePosition(node, handle, handle.position, true); res.push({ ...handle, ...handleXY }); } return res;