diff --git a/src/store/index.ts b/src/store/index.ts index 56ab2c4e..39d64b3b 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -288,8 +288,8 @@ export const storeModel: StoreModel = { ...state.userSelectionRect, x: negativeX ? mousePos.x : state.userSelectionRect.x, y: negativeY ? mousePos.y : state.userSelectionRect.y, - width: negativeX ? startX - mousePos.x : mousePos.x - startX, - height: negativeY ? startY - mousePos.y : mousePos.y - startY, + width: Math.abs(mousePos.x - startX), + height: Math.abs(mousePos.y - startY), }; const selectedNodes = getNodesInside(state.nodes, nextRect, state.transform); diff --git a/src/utils/graph.ts b/src/utils/graph.ts index a1dfdfab..771c8cd9 100644 --- a/src/utils/graph.ts +++ b/src/utils/graph.ts @@ -187,7 +187,7 @@ export const getNodesInside = ( const nBox = rectToBox({ ...position, width, height }); const xOverlap = Math.max(0, Math.min(rBox.x2, nBox.x2) - Math.max(rBox.x, nBox.x)); const yOverlap = Math.max(0, Math.min(rBox.y2, nBox.y2) - Math.max(rBox.y, nBox.y)); - const overlappingArea = xOverlap * yOverlap; + const overlappingArea = Math.ceil(xOverlap * yOverlap); if (width === null || height === null || isDragging) { // at the beginnning all nodes have width & height === 0