fix(connections): fix connections with handles bigger than connec radius closes #2814
This commit is contained in:
@@ -67,6 +67,7 @@ export function handlePointerDown({
|
|||||||
let autoPanStarted = false;
|
let autoPanStarted = false;
|
||||||
let connection: Connection | null = null;
|
let connection: Connection | null = null;
|
||||||
let isValid = false;
|
let isValid = false;
|
||||||
|
let handleDomNode: Element | null = null;
|
||||||
|
|
||||||
const handleLookup = getHandleLookup({
|
const handleLookup = getHandleLookup({
|
||||||
nodes: getNodes(),
|
nodes: getNodes(),
|
||||||
@@ -111,7 +112,7 @@ export function handlePointerDown({
|
|||||||
autoPanStarted = true;
|
autoPanStarted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { handleDomNode, ...result } = isValidHandle(
|
const result = isValidHandle(
|
||||||
event,
|
event,
|
||||||
prevClosestHandle,
|
prevClosestHandle,
|
||||||
connectionMode,
|
connectionMode,
|
||||||
@@ -122,9 +123,13 @@ export function handlePointerDown({
|
|||||||
doc
|
doc
|
||||||
);
|
);
|
||||||
|
|
||||||
|
handleDomNode = result.handleDomNode;
|
||||||
|
connection = result.connection;
|
||||||
|
isValid = result.isValid;
|
||||||
|
|
||||||
setState({
|
setState({
|
||||||
connectionPosition:
|
connectionPosition:
|
||||||
prevClosestHandle && result.isValid
|
prevClosestHandle && isValid
|
||||||
? rendererPointToPoint(
|
? rendererPointToPoint(
|
||||||
{
|
{
|
||||||
x: prevClosestHandle.x,
|
x: prevClosestHandle.x,
|
||||||
@@ -133,16 +138,13 @@ export function handlePointerDown({
|
|||||||
transform
|
transform
|
||||||
)
|
)
|
||||||
: connectionPosition,
|
: connectionPosition,
|
||||||
connectionStatus: getConnectionStatus(!!prevClosestHandle, result.isValid),
|
connectionStatus: getConnectionStatus(!!prevClosestHandle, isValid),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!prevClosestHandle && !result.isValid) {
|
if (!prevClosestHandle && !isValid && !handleDomNode) {
|
||||||
return resetRecentHandle(prevActiveHandle);
|
return resetRecentHandle(prevActiveHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection = result.connection;
|
|
||||||
isValid = result.isValid;
|
|
||||||
|
|
||||||
if (connection.source !== connection.target && handleDomNode) {
|
if (connection.source !== connection.target && handleDomNode) {
|
||||||
resetRecentHandle(prevActiveHandle);
|
resetRecentHandle(prevActiveHandle);
|
||||||
prevActiveHandle = handleDomNode;
|
prevActiveHandle = handleDomNode;
|
||||||
@@ -154,7 +156,7 @@ export function handlePointerDown({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onPointerUp(event: MouseEvent | TouchEvent) {
|
function onPointerUp(event: MouseEvent | TouchEvent) {
|
||||||
if (prevClosestHandle && connection && isValid) {
|
if ((prevClosestHandle || handleDomNode) && connection && isValid) {
|
||||||
onConnect?.(connection);
|
onConnect?.(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +174,7 @@ export function handlePointerDown({
|
|||||||
autoPanStarted = false;
|
autoPanStarted = false;
|
||||||
isValid = false;
|
isValid = false;
|
||||||
connection = null;
|
connection = null;
|
||||||
|
handleDomNode = null;
|
||||||
|
|
||||||
doc.removeEventListener('mousemove', onPointerMove as EventListener);
|
doc.removeEventListener('mousemove', onPointerMove as EventListener);
|
||||||
doc.removeEventListener('mouseup', onPointerUp as EventListener);
|
doc.removeEventListener('mouseup', onPointerUp as EventListener);
|
||||||
|
|||||||
Reference in New Issue
Block a user