fix(selection): handle overlapping area rounding issues closes #610

This commit is contained in:
moklick
2020-10-21 22:13:09 +02:00
parent d489917b66
commit 13a3fd46b1
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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