2
0
Эх сурвалжийг харах

remove cover from fit options

Ryan Di 9 сар өмнө
parent
commit
113dfc0023

+ 0 - 2
excalidraw-app/App.tsx

@@ -681,7 +681,6 @@ const ExcalidrawWrapper = () => {
           //   // scale: 0.01,
           //   // scale: 2,
           //   // origin: "content",
-          //   // fit: "cover",
           //   // scale: 2,
           //   // x: 0,
           //   // y: 0,
@@ -1270,7 +1269,6 @@ const ExcalidrawWrapper = () => {
               >
                 <option value="none">none</option>
                 <option value="contain">contain</option>
-                <option value="cover">cover</option>
               </select>
             </label>
             <label>

+ 1 - 18
packages/excalidraw/scene/export.ts

@@ -197,8 +197,6 @@ export type ExportToCanvasConfig = {
    * order to maintain the aspect ratio. It is recommended to set `position`
    * to `center` when using `fit=contain`.
    *
-   * When `fit` is set to `cover`, padding is disabled (set to 0).
-   *
    * When `fit` is set to `none` and either `width` or `height` or
    * `maxWidthOrHeight` is set, padding is simply adding to the bounding box
    * and the content may overflow the canvas, thus right or bottom padding
@@ -279,8 +277,6 @@ export type ExportToCanvasConfig = {
    *
    * - `none`    - no scaling.
    * - `contain` - scale to fit the frame. Includes `padding`.
-   * - `cover`   - scale to fill the frame while maintaining aspect ratio. If
-   *               content overflows, it will be cropped.
    *
    * If `maxWidthOrHeight` or `widthOrHeight` is set, `fit` is ignored.
    *
@@ -288,7 +284,7 @@ export type ExportToCanvasConfig = {
    * `widthOrHeight` is specified in which case `none` is the default (can be
    * changed). If `x` or `y` are specified, `none` is forced.
    */
-  fit?: "none" | "contain" | "cover";
+  fit?: "none" | "contain";
   /**
    * When either `x` or `y` are not specified, indicates how the canvas should
    * be aligned on the respective axis.
@@ -399,13 +395,6 @@ export const exportToCanvas = async ({
     cfg.fit = "none";
   }
 
-  if (cfg.fit === "cover") {
-    if (cfg.padding && !import.meta.env.PROD) {
-      console.warn("`padding` is ignored when `fit` is set to `cover`");
-    }
-    cfg.padding = 0;
-  }
-
   cfg.padding = cfg.padding ?? 0;
   cfg.scale = cfg.scale ?? 1;
 
@@ -536,12 +525,6 @@ export const exportToCanvas = async ({
       const hRatio = (height - cfg.padding * 2) / height;
       canvasScale = Math.min(wRatio, hRatio);
     }
-  } else if (cfg.fit === "cover") {
-    const wRatio = width / origWidth;
-    const hRatio = height / origHeight;
-    // scale the orig canvas to fill the the target frame
-    // (opposite of "contain")
-    canvasScale = Math.max(wRatio, hRatio);
   }
 
   x = cfg.x ?? origX;