From 913921631b48980f3d991a502f86b7e1b79ec999 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Tue, 7 Jan 2025 22:55:08 +0800 Subject: [PATCH] fix contain dim change --- packages/excalidraw/scene/export.ts | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/packages/excalidraw/scene/export.ts b/packages/excalidraw/scene/export.ts index 6302530e6..010435682 100644 --- a/packages/excalidraw/scene/export.ts +++ b/packages/excalidraw/scene/export.ts @@ -384,8 +384,6 @@ const configExportDimension = async ({ ? "contain" : "none"); - const containPadding = cfg.fit === "contain"; - cfg.padding = cfg.padding ?? 0; cfg.scale = cfg.scale ?? 1; @@ -502,25 +500,13 @@ const configExportDimension = async ({ width = ret.width; height = ret.height; cfg.scale = ret.scale ?? cfg.scale; - } else if (containPadding) { - // const whRatio = width / height; - - // console.log("cfg.padding", cfg.padding); - - // const wRatio = (width - cfg.padding * 2) / width; - // const hRatio = (height - cfg.padding * 2) / height; - // exportScale = Math.min(wRatio, hRatio); - - // width -= cfg.padding * 2; - // height -= (cfg.padding * 2) / whRatio; - - const whRatio = width / height; + } else if (cfg.fit === "contain") { width -= cfg.padding * 2; - height -= (cfg.padding * 2) / whRatio; + height -= cfg.padding * 2; const wRatio = width / origWidth; const hRatio = height / origHeight; - // scale the orig canvas to fit in the target frame + // scale the orig canvas to fit in the target region exportScale = Math.min(wRatio, hRatio); }