feat: improve zoom-to-content when creating flowchart (#8368)

This commit is contained in:
David Luzar
2024-08-12 20:42:08 +02:00
committed by GitHub
parent 8420e1aa13
commit 4320a3cf41
4 changed files with 107 additions and 30 deletions
+5 -3
View File
@@ -738,6 +738,7 @@ export const getElementBounds = (
export const getCommonBounds = (
elements: readonly ExcalidrawElement[],
elementsMap?: ElementsMap,
): Bounds => {
if (!elements.length) {
return [0, 0, 0, 0];
@@ -748,10 +749,11 @@ export const getCommonBounds = (
let minY = Infinity;
let maxY = -Infinity;
const elementsMap = arrayToMap(elements);
elements.forEach((element) => {
const [x1, y1, x2, y2] = getElementBounds(element, elementsMap);
const [x1, y1, x2, y2] = getElementBounds(
element,
elementsMap || arrayToMap(elements),
);
minX = Math.min(minX, x1);
minY = Math.min(minY, y1);
maxX = Math.max(maxX, x2);