simplify conditions

This commit is contained in:
peterkogo
2025-10-28 14:00:05 +01:00
parent eb7a27251a
commit 2baa839138
2 changed files with 10 additions and 14 deletions

View File

@@ -81,6 +81,7 @@
// We start the selection process when the user clicks down on the pane
function onPointerDownCapture(event: PointerEvent) {
containerBounds = container?.getBoundingClientRect();
if (!containerBounds) return;
const eventTargetIsContainer = event.target === container;
@@ -88,15 +89,13 @@
!eventTargetIsContainer && !!(event.target as HTMLElement).closest('.nokey');
const isSelectionActive =
(selectionOnDrag && eventTargetIsContainer) || !selectionOnDrag || store.selectionKeyPressed;
(selectionOnDrag && eventTargetIsContainer) || store.selectionKeyPressed;
if (
!store.elementsSelectable ||
!isSelecting ||
event.button !== 0 ||
!containerBounds ||
isNoKeyEvent ||
!isSelecting ||
!isSelectionActive ||
event.button !== 0 ||
!event.isPrimary
) {
return;
@@ -122,7 +121,7 @@
event.preventDefault();
}
if (paneClickDistance === 0 || !selectionOnDrag) {
if (paneClickDistance === 0 || store.selectionKeyPressed) {
store.unselectNodesAndEdges();
onselectionstart?.(event);
@@ -219,8 +218,8 @@
store.selectionRect = null;
if (selectionInProgress && selectedNodeIds.size > 0) {
store.selectionRectMode = 'nodes';
if (selectionInProgress) {
store.selectionRectMode = selectedNodeIds.size > 0 ? 'nodes' : null;
}
if (selectionInProgress) {