mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-08-29 05:07:08 +02:00
fix: upscaling behavior after change of background
This commit is contained in:
@@ -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(() => {
|
||||||
|
Reference in New Issue
Block a user