added check to xyhandle pointermove if connection is cancelled

This commit is contained in:
peterkogo
2024-03-13 14:26:27 +01:00
parent 09118c1c8e
commit e489df9808
3 changed files with 9 additions and 1 deletions

View File

@@ -140,6 +140,7 @@ function HandleComponent(
onConnect: onConnectExtended,
isValidConnection: isValidConnection || currentStore.isValidConnection,
getTransform: () => store.getState().transform,
getConnectionStartHandle: () => store.getState().connectionStartHandle,
});
}

View File

@@ -99,7 +99,8 @@
onConnectEnd: (event) => {
$onConnectEndAction?.(event);
},
getTransform: () => [$viewport.x, $viewport.y, $viewport.zoom]
getTransform: () => [$viewport.x, $viewport.y, $viewport.zoom],
getConnectionStartHandle: () => $connection.startHandle
});
}
}

View File

@@ -38,6 +38,7 @@ export type OnPointerDownParams = {
isValidConnection?: IsValidConnection;
onEdgeUpdateEnd?: (evt: MouseEvent | TouchEvent) => void;
getTransform: () => Transform;
getConnectionStartHandle: () => ConnectingHandle | null;
};
export type IsValidParams = {
@@ -91,6 +92,7 @@ function onPointerDown(
onEdgeUpdateEnd,
updateConnection,
getTransform,
getConnectionStartHandle,
}: OnPointerDownParams
) {
// when xyflow is used inside a shadow root we can't use document
@@ -149,6 +151,10 @@ function onPointerDown(
onConnectStart?.(event, { nodeId, handleId, handleType });
function onPointerMove(event: MouseEvent | TouchEvent) {
if (!getConnectionStartHandle()) {
onPointerUp(event);
}
const transform = getTransform();
connectionPosition = getEventPosition(event, containerBounds);
closestHandle = getClosestHandle(