feat: improve zoom-to-content when creating flowchart (#8368)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user