chore(pane): cleanup
This commit is contained in:
@@ -95,8 +95,6 @@ export function Pane({
|
|||||||
const selectionInProgress = useRef<boolean>(false);
|
const selectionInProgress = useRef<boolean>(false);
|
||||||
const selectionStarted = useRef<boolean>(false);
|
const selectionStarted = useRef<boolean>(false);
|
||||||
|
|
||||||
const isNoKeyEvent = useRef<boolean | null>(null);
|
|
||||||
|
|
||||||
const onClick = (event: ReactMouseEvent) => {
|
const onClick = (event: ReactMouseEvent) => {
|
||||||
// We prevent click events when the user let go of the selectionKey during a selection
|
// We prevent click events when the user let go of the selectionKey during a selection
|
||||||
// We also prevent click events when a connection is in progress
|
// We also prevent click events when a connection is in progress
|
||||||
@@ -121,13 +119,12 @@ export function Pane({
|
|||||||
|
|
||||||
const onWheel = onPaneScroll ? (event: React.WheelEvent) => onPaneScroll(event) : undefined;
|
const onWheel = onPaneScroll ? (event: React.WheelEvent) => onPaneScroll(event) : undefined;
|
||||||
|
|
||||||
const onClickCapture = (event: ReactMouseEvent) => {
|
const onClickCapture = (event: ReactMouseEvent) => event.stopPropagation();
|
||||||
event.stopPropagation();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onPointerDown = (event: ReactPointerEvent): void => {
|
const onPointerDown = (event: ReactPointerEvent): void => {
|
||||||
const { resetSelectedElements, domNode } = store.getState();
|
const { resetSelectedElements, domNode } = store.getState();
|
||||||
containerBounds.current = domNode?.getBoundingClientRect();
|
containerBounds.current = domNode?.getBoundingClientRect();
|
||||||
|
|
||||||
const isNoKeyEvent = event.target !== container.current && !!(event.target as HTMLElement).closest('.nokey');
|
const isNoKeyEvent = event.target !== container.current && !!(event.target as HTMLElement).closest('.nokey');
|
||||||
|
|
||||||
if (!elementsSelectable || !isSelecting || event.button !== 0 || !containerBounds.current || isNoKeyEvent) {
|
if (!elementsSelectable || !isSelecting || event.button !== 0 || !containerBounds.current || isNoKeyEvent) {
|
||||||
@@ -232,14 +229,12 @@ export function Pane({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onPointerUp = (event: ReactPointerEvent) => {
|
const onPointerUp = (event: ReactPointerEvent) => {
|
||||||
console.log('onPointerUp');
|
|
||||||
if (event.button !== 0 || !selectionStarted.current) {
|
if (event.button !== 0 || !selectionStarted.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(event.target as Partial<Element>)?.releasePointerCapture?.(event.pointerId);
|
(event.target as Partial<Element>)?.releasePointerCapture?.(event.pointerId);
|
||||||
const { userSelectionRect } = store.getState();
|
const { userSelectionRect } = store.getState();
|
||||||
isNoKeyEvent.current = null;
|
|
||||||
/*
|
/*
|
||||||
* We only want to trigger click functions when in selection mode if
|
* We only want to trigger click functions when in selection mode if
|
||||||
* the user did not move the mouse.
|
* the user did not move the mouse.
|
||||||
@@ -275,7 +270,6 @@ export function Pane({
|
|||||||
onContextMenu={wrapHandler(onContextMenu, container)}
|
onContextMenu={wrapHandler(onContextMenu, container)}
|
||||||
onWheel={wrapHandler(onWheel, container)}
|
onWheel={wrapHandler(onWheel, container)}
|
||||||
onPointerEnter={hasActiveSelection ? undefined : onPaneMouseEnter}
|
onPointerEnter={hasActiveSelection ? undefined : onPaneMouseEnter}
|
||||||
onPointerDown={hasActiveSelection ? undefined : onPaneMouseMove}
|
|
||||||
onPointerMove={hasActiveSelection ? onPointerMove : onPaneMouseMove}
|
onPointerMove={hasActiveSelection ? onPointerMove : onPaneMouseMove}
|
||||||
onPointerUp={hasActiveSelection ? onPointerUp : undefined}
|
onPointerUp={hasActiveSelection ? onPointerUp : undefined}
|
||||||
onPointerDownCapture={hasActiveSelection ? onPointerDown : undefined}
|
onPointerDownCapture={hasActiveSelection ? onPointerDown : undefined}
|
||||||
|
|||||||
Reference in New Issue
Block a user