fix resize drawRender issue

This commit is contained in:
Sanster 2022-04-24 21:52:41 +08:00
parent bbeefba7c5
commit bbacb99e9d

View File

@ -245,14 +245,7 @@ export default function Editor(props: EditorProps) {
if (context?.canvas) { if (context?.canvas) {
context.canvas.width = original.naturalWidth context.canvas.width = original.naturalWidth
context.canvas.height = original.naturalHeight context.canvas.height = original.naturalHeight
drawOnCurrentRender([])
context.drawImage(
original,
0,
0,
original.naturalWidth,
original.naturalHeight
)
} }
if (!initialCentered) { if (!initialCentered) {
@ -283,7 +276,7 @@ export default function Editor(props: EditorProps) {
viewport.state.scale = minScale viewport.state.scale = minScale
setScale(minScale) setScale(minScale)
setPanned(false) setPanned(false)
}, [viewportRef, minScale, original, windowSize, panned]) }, [viewportRef, minScale, original, windowSize])
useEffect(() => { useEffect(() => {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
@ -495,9 +488,10 @@ export default function Editor(props: EditorProps) {
function download() { function download() {
const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1') const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1')
const currRender = renders[renders.length - 1] const curRender = renders[renders.length - 1]
downloadImage(currRender.currentSrc, name) downloadImage(curRender.currentSrc, name)
} }
const onSizeLimitChange = (_sizeLimit: number) => { const onSizeLimitChange = (_sizeLimit: number) => {
setSizeLimit(_sizeLimit) setSizeLimit(_sizeLimit)
} }