liwei 1 년 전
부모
커밋
f9a8ac5559
2개의 변경된 파일16개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 2
      src/modules/editor/components/Viewport/Content/index.tsx
  2. 11 4
      src/modules/editor/controllers/EditorCtrl/index.ts

+ 5 - 2
src/modules/editor/components/Viewport/Content/index.tsx

@@ -1,7 +1,7 @@
 import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
 import { css } from "@linaria/core";
 import { defineUI } from "queenjs";
-import { onUnmounted, reactive, ref } from "vue";
+import { onUnmounted, reactive, ref , nextTick} from "vue";
 import { Container, Draggable } from "vue-dndrop";
 import { useEditor } from "../../..";
 import { HotKeyCtrl } from "../../../controllers/HotKeyCtrl";
@@ -91,7 +91,10 @@ export default defineUI({
                         onClick={() => {
                           actions.selectObjs([]);
                           actions.pickComp(item, false);
-                          controls.editorCtrl.autoInScreen();
+
+                          nextTick(()=>{
+                            controls.editorCtrl.autoInScreen();
+                          })
                         }}
                       >
                         {store.streamCardIds.length > 1 && (

+ 11 - 4
src/modules/editor/controllers/EditorCtrl/index.ts

@@ -106,14 +106,21 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
     });
 
     parent.addEventListener("wheel", (event: any) => {
+      event.preventDefault();
+
       // 检查滚轮方向
       let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail));
       console.log(delta);
 
-      let s = this.state.scale + 0.1 * delta;
-      if (s < 0.5) s = 0.5;
-      if (s > 2) s = 2.0;
-      this.state.setScale(s);
+      if (event.ctrlKey) {//按住ctrl进行缩放
+        let s = this.state.scale + 0.1 * delta;
+        if (s < 0.5) s = 0.5;
+        if (s > 2) s = 2.0;
+        this.state.setScale(s);
+        return;
+      }
+      obj.translate(0,  30 * delta)
+      editorLayer.style.transform = obj.parent.worldTransform.getMatrixStr();
     });
 
     let isMoving = false;