remove cover from fit options

pull/6086/head
Ryan Di 2 months ago
parent 96b5cfc35d
commit 113dfc0023

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

@ -197,8 +197,6 @@ export type ExportToCanvasConfig = {
* order to maintain the aspect ratio. It is recommended to set `position` * order to maintain the aspect ratio. It is recommended to set `position`
* to `center` when using `fit=contain`. * 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 * When `fit` is set to `none` and either `width` or `height` or
* `maxWidthOrHeight` is set, padding is simply adding to the bounding box * `maxWidthOrHeight` is set, padding is simply adding to the bounding box
* and the content may overflow the canvas, thus right or bottom padding * and the content may overflow the canvas, thus right or bottom padding
@ -279,8 +277,6 @@ export type ExportToCanvasConfig = {
* *
* - `none` - no scaling. * - `none` - no scaling.
* - `contain` - scale to fit the frame. Includes `padding`. * - `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. * 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 * `widthOrHeight` is specified in which case `none` is the default (can be
* changed). If `x` or `y` are specified, `none` is forced. * 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 * When either `x` or `y` are not specified, indicates how the canvas should
* be aligned on the respective axis. * be aligned on the respective axis.
@ -399,13 +395,6 @@ export const exportToCanvas = async ({
cfg.fit = "none"; 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.padding = cfg.padding ?? 0;
cfg.scale = cfg.scale ?? 1; cfg.scale = cfg.scale ?? 1;
@ -536,12 +525,6 @@ export const exportToCanvas = async ({
const hRatio = (height - cfg.padding * 2) / height; const hRatio = (height - cfg.padding * 2) / height;
canvasScale = Math.min(wRatio, hRatio); 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; x = cfg.x ?? origX;

Loading…
Cancel
Save