merge with master

This commit is contained in:
Ryan Di 2023-11-22 17:23:13 +08:00
commit 14eecf651f
2 changed files with 16 additions and 2 deletions

View File

@ -96,7 +96,7 @@
"vitest-canvas-mock": "0.3.2" "vitest-canvas-mock": "0.3.2"
}, },
"engines": { "engines": {
"node": "^18.0.0" "node": "18.0.0 - 20.x.x"
}, },
"homepage": ".", "homepage": ".",
"name": "excalidraw", "name": "excalidraw",

View File

@ -265,7 +265,21 @@ export const zoomToFit = ({
30.0, 30.0,
) as NormalizedZoomValue; ) as NormalizedZoomValue;
scrollX = (appState.width / 2) * (1 / newZoomValue) - centerX; let appStateWidth = appState.width;
if (appState.openSidebar) {
const sidebarDOMElem = document.querySelector(
".sidebar",
) as HTMLElement | null;
const sidebarWidth = sidebarDOMElem?.offsetWidth ?? 0;
const isRTL = document.documentElement.getAttribute("dir") === "rtl";
appStateWidth = !isRTL
? appState.width - sidebarWidth
: appState.width + sidebarWidth;
}
scrollX = (appStateWidth / 2) * (1 / newZoomValue) - centerX;
scrollY = (appState.height / 2) * (1 / newZoomValue) - centerY; scrollY = (appState.height / 2) * (1 / newZoomValue) - centerY;
} else { } else {
newZoomValue = zoomValueToFitBoundsOnViewport(commonBounds, { newZoomValue = zoomValueToFitBoundsOnViewport(commonBounds, {