Get clicked handle element from event.currentTarget

This commit is contained in:
Karlo Bistrički
2025-07-31 15:55:11 +02:00
parent bb5bf60e5d
commit 428f2e8fb9
3 changed files with 5 additions and 4 deletions
@@ -120,6 +120,7 @@ function HandleComponent(
return; return;
} }
const handleElement = event.currentTarget
const isMouseTriggered = isMouseEvent(event.nativeEvent); const isMouseTriggered = isMouseEvent(event.nativeEvent);
if ( if (
@@ -128,7 +129,7 @@ function HandleComponent(
) { ) {
const currentStore = store.getState(); const currentStore = store.getState();
XYHandle.onPointerDown(event.nativeEvent, { XYHandle.onPointerDown(event.nativeEvent, handleElement, {
autoPanOnConnect: currentStore.autoPanOnConnect, autoPanOnConnect: currentStore.autoPanOnConnect,
connectionMode: currentStore.connectionMode, connectionMode: currentStore.connectionMode,
connectionRadius: currentStore.connectionRadius, connectionRadius: currentStore.connectionRadius,
+2 -2
View File
@@ -22,6 +22,7 @@ const alwaysValid = () => true;
function onPointerDown( function onPointerDown(
event: MouseEvent | TouchEvent, event: MouseEvent | TouchEvent,
handleElement: Element,
{ {
connectionMode, connectionMode,
connectionRadius, connectionRadius,
@@ -54,8 +55,7 @@ function onPointerDown(
let closestHandle: Handle | null; let closestHandle: Handle | null;
const { x, y } = getEventPosition(event); const { x, y } = getEventPosition(event);
const clickedHandle = doc?.elementFromPoint(x, y); const handleType = getHandleType(edgeUpdaterType, handleElement);
const handleType = getHandleType(edgeUpdaterType, clickedHandle);
const containerBounds = domNode?.getBoundingClientRect(); const containerBounds = domNode?.getBoundingClientRect();
let connectionStarted = false; let connectionStarted = false;
+1 -1
View File
@@ -54,7 +54,7 @@ export type IsValidParams = {
}; };
export type XYHandleInstance = { export type XYHandleInstance = {
onPointerDown: (event: MouseEvent | TouchEvent, params: OnPointerDownParams) => void; onPointerDown: (event: MouseEvent | TouchEvent, handleElement: Element, params: OnPointerDownParams) => void;
isValid: (event: MouseEvent | TouchEvent, params: IsValidParams) => Result; isValid: (event: MouseEvent | TouchEvent, params: IsValidParams) => Result;
}; };