From 9747e0f51617f4fd440c66c4c48ada0dfbbd8ba0 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 26 Jul 2022 15:16:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E7=94=BB=E5=B8=83=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E4=B8=8EstageRect=E9=85=8D=E7=BD=AE=E4=B8=8D=E7=9B=B8?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/components/ScrollViewer.vue | 2 +- packages/editor/src/services/ui.ts | 10 ++++++++-- packages/editor/src/theme/stage.scss | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/ScrollViewer.vue b/packages/editor/src/components/ScrollViewer.vue index a2b8b00c..2c078861 100644 --- a/packages/editor/src/components/ScrollViewer.vue +++ b/packages/editor/src/components/ScrollViewer.vue @@ -55,7 +55,7 @@ export default defineComponent({ style: computed( () => ` width: ${props.width}px; - height: ${(props.height || 0) - 40}px; + height: ${props.height}px; position: absolute; margin-top: 30px; `, diff --git a/packages/editor/src/services/ui.ts b/packages/editor/src/services/ui.ts index 63e087a0..169c60cd 100644 --- a/packages/editor/src/services/ui.ts +++ b/packages/editor/src/services/ui.ts @@ -155,10 +155,16 @@ class Ui extends BaseService { const { stageRect, stageContainerRect } = state; const { height, width } = stageContainerRect; if (!width || !height) return 1; - if (width > stageRect.width && height > stageRect.height) { + + // 30为标尺的大小 + const stageWidth = stageRect.width + 30; + const stageHeight = stageRect.height + 30; + + if (width > stageWidth && height > stageHeight) { return 1; } - return Math.min((width - 100) / stageRect.width || 1, (height - 100) / stageRect.height || 1); + // 60/80是为了不要让画布太过去贴住四周(这样好看些) + return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1); } } diff --git a/packages/editor/src/theme/stage.scss b/packages/editor/src/theme/stage.scss index cb7ea2b3..caffe8eb 100644 --- a/packages/editor/src/theme/stage.scss +++ b/packages/editor/src/theme/stage.scss @@ -13,9 +13,9 @@ height: 100%; z-index: 0; position: relative; - border: 1px solid $--border-color; transition: transform 0.3s; box-sizing: content-box; + box-shadow: rgba(0, 0, 0, 0.04) 0px 3px 5px; &::-webkit-scrollbar { width: 0 !important;