mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: upscaling behavior after change of background
This commit is contained in:
parent
8b86ef4c60
commit
c2870a6df5
1 changed files with 21 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
|
||||||
import type { ActionManager } from "../actions/manager";
|
import type { ActionManager } from "../actions/manager";
|
||||||
|
@ -113,7 +113,16 @@ const ImageExportModal = ({
|
||||||
})
|
})
|
||||||
: elements;
|
: elements;
|
||||||
|
|
||||||
//FIXME: this is broken by fix for padding in export preview
|
const updateAllScales = useCallback(
|
||||||
|
(scale: number) => {
|
||||||
|
actionManager.executeAction(actionChangeExportScale, "ui", scale);
|
||||||
|
setExportScale(scale);
|
||||||
|
setExportBaseScale(scale);
|
||||||
|
},
|
||||||
|
[actionManager, setExportScale, setExportBaseScale],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Upscale exported image when is smaller than preview
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
exportedElements.length > 0 &&
|
exportedElements.length > 0 &&
|
||||||
|
@ -142,20 +151,21 @@ const ImageExportModal = ({
|
||||||
) / 100;
|
) / 100;
|
||||||
|
|
||||||
if (scale > 1) {
|
if (scale > 1) {
|
||||||
actionManager.executeAction(actionChangeExportScale, "ui", scale);
|
if (scale !== exportBaseScale) {
|
||||||
setExportBaseScale(scale);
|
updateAllScales(scale);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setExportBaseScale(defaultExportScale);
|
updateAllScales(defaultExportScale);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (exportBaseScale !== defaultExportScale) {
|
||||||
setExportBaseScale(defaultExportScale);
|
updateAllScales(defaultExportScale);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
actionManager,
|
|
||||||
exportedElements,
|
|
||||||
previewRef,
|
|
||||||
exportWithBackground,
|
|
||||||
exportBackgroundImage,
|
exportBackgroundImage,
|
||||||
|
exportWithBackground,
|
||||||
|
exportedElements,
|
||||||
|
exportBaseScale,
|
||||||
|
updateAllScales,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue