fix(reconnect): use connectionDragThreshold

This commit is contained in:
moklick
2025-06-17 12:10:20 +02:00
parent f98c1c8a59
commit 46b2626273
3 changed files with 24 additions and 10 deletions
@@ -1,5 +1,12 @@
// Reconnectable edges have a anchors around their handles to reconnect the edge.
import { XYHandle, type Connection, EdgePosition, FinalConnectionState, HandleType } from '@xyflow/system';
import {
XYHandle,
type Connection,
EdgePosition,
FinalConnectionState,
HandleType,
OnConnectStart,
} from '@xyflow/system';
import { EdgeAnchor } from '../Edges/EdgeAnchor';
import type { EdgeWrapperProps, Edge } from '../../types/edges';
@@ -60,15 +67,17 @@ export function EdgeUpdateAnchors<EdgeType extends Edge = Edge>({
} = store.getState();
const isTarget = oppositeHandle.type === 'target';
setReconnecting(true);
onReconnectStart?.(event, edge, oppositeHandle.type);
const _onReconnectEnd = (evt: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => {
setReconnecting(false);
onReconnectEnd?.(evt, edge, oppositeHandle.type, connectionState);
};
const onConnectEdge = (connection: Connection) => onReconnect?.(edge, connection);
const _onConnectStart: OnConnectStart = (_event, params) => {
setReconnecting(true);
onReconnectStart?.(event, edge, oppositeHandle.type);
onConnectStart?.(_event, params);
};
XYHandle.onPointerDown(event.nativeEvent, {
autoPanOnConnect,
@@ -86,7 +95,7 @@ export function EdgeUpdateAnchors<EdgeType extends Edge = Edge>({
panBy,
isValidConnection,
onConnect: onConnectEdge,
onConnectStart,
onConnectStart: _onConnectStart,
onConnectEnd,
onReconnectEnd: _onReconnectEnd,
updateConnection,