also postpone starting selection when clicking on a node
This commit is contained in:
@@ -121,7 +121,7 @@ export function Pane({
|
|||||||
// We are using capture here in order to prevent other pointer events
|
// We are using capture here in order to prevent other pointer events
|
||||||
// to be able to create a selection above a node or an edge
|
// to be able to create a selection above a node or an edge
|
||||||
const onPointerDownCapture = (event: ReactPointerEvent): void => {
|
const onPointerDownCapture = (event: ReactPointerEvent): void => {
|
||||||
const { resetSelectedElements, domNode } = store.getState();
|
const { domNode } = store.getState();
|
||||||
containerBounds.current = domNode?.getBoundingClientRect();
|
containerBounds.current = domNode?.getBoundingClientRect();
|
||||||
if (!containerBounds.current) return;
|
if (!containerBounds.current) return;
|
||||||
|
|
||||||
@@ -155,13 +155,6 @@ export function Pane({
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paneClickDistance === 0 || selectionKeyPressed) {
|
|
||||||
resetSelectedElements();
|
|
||||||
|
|
||||||
onSelectionStart?.(event);
|
|
||||||
selectionInProgress.current = true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPointerMove = (event: ReactPointerEvent): void => {
|
const onPointerMove = (event: ReactPointerEvent): void => {
|
||||||
@@ -184,14 +177,10 @@ export function Pane({
|
|||||||
const { x: mouseX, y: mouseY } = getEventPosition(event.nativeEvent, containerBounds.current);
|
const { x: mouseX, y: mouseY } = getEventPosition(event.nativeEvent, containerBounds.current);
|
||||||
const { startX, startY } = userSelectionRect;
|
const { startX, startY } = userSelectionRect;
|
||||||
|
|
||||||
if (
|
if (!selectionInProgress.current) {
|
||||||
!selectionInProgress.current &&
|
const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance;
|
||||||
event.target === container.current &&
|
|
||||||
!selectionKeyPressed &&
|
|
||||||
paneClickDistance > 0
|
|
||||||
) {
|
|
||||||
const distance = Math.hypot(mouseX - startX, mouseY - startY);
|
const distance = Math.hypot(mouseX - startX, mouseY - startY);
|
||||||
if (distance <= paneClickDistance) {
|
if (distance <= requiredDistance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resetSelectedElements();
|
resetSelectedElements();
|
||||||
|
|||||||
Reference in New Issue
Block a user