fix(graph.ts): overlapping area calculation
This commit is contained in:
@@ -200,6 +200,14 @@ const storeModel: StoreModel = {
|
|||||||
selection,
|
selection,
|
||||||
state.transform
|
state.transform
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!selectedNodes.length) {
|
||||||
|
state.nodesSelectionActive = false;
|
||||||
|
state.selectedElements = [];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const selectedNodesBbox = getRectOfNodes(selectedNodes);
|
const selectedNodesBbox = getRectOfNodes(selectedNodes);
|
||||||
|
|
||||||
state.selection = selection;
|
state.selection = selection;
|
||||||
|
|||||||
+5
-2
@@ -152,10 +152,13 @@ export const getNodesInside = (
|
|||||||
width: rect.width / tScale,
|
width: rect.width / tScale,
|
||||||
height: rect.height / tScale,
|
height: rect.height / tScale,
|
||||||
});
|
});
|
||||||
|
|
||||||
return nodes.filter(({ __rg: { position, width, height } }) => {
|
return nodes.filter(({ __rg: { position, width, height } }) => {
|
||||||
const nBox = rectToBox({ ...position, width, height });
|
const nBox = rectToBox({ ...position, width, height });
|
||||||
const overlappingArea =
|
const xOverlap = Math.max(0, Math.min(rBox.x2, nBox.x2) - Math.max(rBox.x, nBox.x));
|
||||||
(Math.max(rBox.x, nBox.x) - Math.min(rBox.x2, nBox.x2)) * (Math.max(rBox.y, nBox.y) - Math.min(rBox.y2, nBox.y2));
|
const yOverlap = Math.max(0, Math.min(rBox.y2, nBox.y2) - Math.max(rBox.y, nBox.y));
|
||||||
|
const overlappingArea = xOverlap * yOverlap;
|
||||||
|
|
||||||
if (partially) {
|
if (partially) {
|
||||||
return overlappingArea >= 0;
|
return overlappingArea >= 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user