fixed reconnect with connectionMode=loose
This commit is contained in:
@@ -61,7 +61,7 @@ function onPointerDown(
|
||||
return;
|
||||
}
|
||||
|
||||
const fromHandleInternal = getHandle(nodeId, handleType, handleId, nodeLookup);
|
||||
const fromHandleInternal = getHandle(nodeId, handleType, handleId, nodeLookup, connectionMode);
|
||||
if (!fromHandleInternal) {
|
||||
return;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ function isValidHandle(
|
||||
|
||||
result.isValid = isValid && isValidConnection(connection);
|
||||
|
||||
result.toHandle = getHandle(handleNodeId, handleType, handleId, nodeLookup, false);
|
||||
result.toHandle = getHandle(handleNodeId, handleType, handleId, nodeLookup, connectionMode, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getHandlePosition, getOverlappingArea, nodeToRect } from '../utils';
|
||||
import type { HandleType, XYPosition, Handle, InternalNodeBase, NodeLookup } from '../types';
|
||||
import type { HandleType, XYPosition, Handle, InternalNodeBase, NodeLookup, ConnectionMode } from '../types';
|
||||
|
||||
function getNodesWithinDistance(position: XYPosition, nodeLookup: NodeLookup, distance: number): InternalNodeBase[] {
|
||||
const nodes: InternalNodeBase[] = [];
|
||||
@@ -78,6 +78,7 @@ export function getHandle(
|
||||
handleType: HandleType,
|
||||
handleId: string | null,
|
||||
nodeLookup: NodeLookup,
|
||||
connectionMode: ConnectionMode,
|
||||
withAbsolutePosition = false
|
||||
): Handle | null {
|
||||
const node = nodeLookup.get(nodeId);
|
||||
@@ -85,7 +86,10 @@ export function getHandle(
|
||||
return null;
|
||||
}
|
||||
|
||||
const handles = node.internals.handleBounds?.[handleType];
|
||||
const handles =
|
||||
connectionMode === 'strict'
|
||||
? node.internals.handleBounds?.[handleType]
|
||||
: [...(node.internals.handleBounds?.source ?? []), ...(node.internals.handleBounds?.target ?? [])];
|
||||
const handle = (handleId ? handles?.find((h) => h.id === handleId) : handles?.[0]) ?? null;
|
||||
|
||||
return handle && withAbsolutePosition
|
||||
|
||||
Reference in New Issue
Block a user