|
@@ -9,6 +9,13 @@ export function normalizeScroll(pos: number) {
|
|
|
export function calculateScrollCenter(
|
|
|
elements: readonly ExcalidrawElement[],
|
|
|
): { scrollX: FlooredNumber; scrollY: FlooredNumber } {
|
|
|
+ if (!elements.length) {
|
|
|
+ return {
|
|
|
+ scrollX: normalizeScroll(0),
|
|
|
+ scrollY: normalizeScroll(0),
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
const [x1, y1, x2, y2] = getCommonBounds(elements);
|
|
|
|
|
|
const centerX = (x1 + x2) / 2;
|