fix(selection): handle overlapping area rounding issues closes #610
This commit is contained in:
+2
-2
@@ -288,8 +288,8 @@ export const storeModel: StoreModel = {
|
|||||||
...state.userSelectionRect,
|
...state.userSelectionRect,
|
||||||
x: negativeX ? mousePos.x : state.userSelectionRect.x,
|
x: negativeX ? mousePos.x : state.userSelectionRect.x,
|
||||||
y: negativeY ? mousePos.y : state.userSelectionRect.y,
|
y: negativeY ? mousePos.y : state.userSelectionRect.y,
|
||||||
width: negativeX ? startX - mousePos.x : mousePos.x - startX,
|
width: Math.abs(mousePos.x - startX),
|
||||||
height: negativeY ? startY - mousePos.y : mousePos.y - startY,
|
height: Math.abs(mousePos.y - startY),
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedNodes = getNodesInside(state.nodes, nextRect, state.transform);
|
const selectedNodes = getNodesInside(state.nodes, nextRect, state.transform);
|
||||||
|
|||||||
+1
-1
@@ -187,7 +187,7 @@ export const getNodesInside = (
|
|||||||
const nBox = rectToBox({ ...position, width, height });
|
const nBox = rectToBox({ ...position, width, height });
|
||||||
const xOverlap = Math.max(0, Math.min(rBox.x2, nBox.x2) - Math.max(rBox.x, nBox.x));
|
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 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) {
|
if (width === null || height === null || isDragging) {
|
||||||
// at the beginnning all nodes have width & height === 0
|
// at the beginnning all nodes have width & height === 0
|
||||||
|
|||||||
Reference in New Issue
Block a user