From 486f497ac859e1c0edf2dfde7f4159507e361641 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sat, 29 Oct 2022 16:34:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E6=AF=94=E4=BE=8B=E8=AE=A1=E7=AE=97=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Editor/Canvas/hooks/useViewportSize.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/views/Editor/Canvas/hooks/useViewportSize.ts b/src/views/Editor/Canvas/hooks/useViewportSize.ts index 07f5dfe7..c869533a 100644 --- a/src/views/Editor/Canvas/hooks/useViewportSize.ts +++ b/src/views/Editor/Canvas/hooks/useViewportSize.ts @@ -42,7 +42,12 @@ export default (canvasRef: Ref) => { const newViewportActualHeight = canvasHeight * (newValue / 100) const oldViewportActualHeight = canvasHeight * (oldValue / 100) - mainStore.setCanvasScale(newViewportActualWidth / VIEWPORT_SIZE) + if (canvasHeight / canvasWidth > viewportRatio.value) { + mainStore.setCanvasScale(newViewportActualWidth / VIEWPORT_SIZE) + } + else { + mainStore.setCanvasScale(newViewportActualHeight / (VIEWPORT_SIZE * viewportRatio.value)) + } viewportLeft.value = viewportLeft.value - (newViewportActualWidth - oldViewportActualWidth) / 2 viewportTop.value = viewportTop.value - (newViewportActualHeight - oldViewportActualHeight) / 2 }