瀏覽代碼

fix: #2390 [Preview]缩小后scale为负值 (#2391)

tnnevol 2 年之前
父節點
當前提交
4e16438494
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      src/components/Preview/src/Functional.vue

+ 9 - 1
src/components/Preview/src/Functional.vue

@@ -141,8 +141,16 @@
       }
       // 缩放函数
       function scaleFunc(num: number) {
+        // 最小缩放
+        const MIN_SCALE = 0.02;
+        // 放大缩小的颗粒度
+        const GRA = 0.1;
         if (imgState.imgScale <= 0.2 && num < 0) return;
-        imgState.imgScale += num;
+        imgState.imgScale += num * GRA;
+        // scale 不能 < 0,否则图片会倒置放大
+        if (imgState.imgScale < 0) {
+          imgState.imgScale = MIN_SCALE;
+        }
       }
 
       // 旋转图片