Browse Source

fixed move bug

liwei 1 year ago
parent
commit
14d11985dc

+ 1 - 0
src/modules/editor/components/CompUI/basicUI/Transfer/index.tsx

@@ -22,6 +22,7 @@ export const Transfer = defineComponent({
 
     onUnmounted(() => {
       transferCtrl.destroy();
+      console.log("transferCtrl.destroy========================")
     });
 
     return () => {

+ 9 - 6
src/modules/editor/components/CompUI/basicUI/Transfer/streamCard.tsx

@@ -2,13 +2,14 @@ import { css } from "@linaria/core";
 import { defineComponent, onMounted, onUnmounted } from "vue";
 import { useEditor } from "../../../..";
 import { IconMove, IconClear, IconAdd, IconResizeY } from "@/assets/icons";
+import { TransferCtrl } from "@/modules/editor/controllers/TransferCtrl";
 
 export const StreamCardTransfer = defineComponent({
   setup() {
     const editor = useEditor();
-    const { store, controls, helper } = editor;
-    const { streamCardTransferCtrl } = controls;
-  
+    const { store, helper } = editor;
+
+    const streamCardTransferCtrl = new TransferCtrl(editor);
     onMounted(() => {
         const pageEl = helper.findRootComp()?.$el;
         if (pageEl) {
@@ -24,7 +25,6 @@ export const StreamCardTransfer = defineComponent({
     });
 
     return () => {
-       
         const transferStyle = streamCardTransferCtrl.transferStyle;
 
       return (
@@ -48,8 +48,11 @@ export const StreamCardTransfer = defineComponent({
             <div
               class={resizeHeightBtnCls}
               style={{ top: transferStyle.height }}
-              onMousedown={(e) =>
-                streamCardTransferCtrl.mousedown(e, "resizeY")
+                onMousedown={(e) => {
+                    e.stopPropagation();
+                    
+                    streamCardTransferCtrl.mousedown(e, "resizeY")
+                }
               }
             >
               <IconResizeY />

+ 3 - 1
src/modules/editor/components/CompUI/basicUI/View.tsx

@@ -37,7 +37,9 @@ export const View = defineComponent({
               e.stopPropagation();
               if (store.isEditMode) {
                 actions.pickComp(props.compId);
-                controls.transferCtrl.mousedown(e, "move")
+                if (!helper.isStreamCard(props.compId) ) {
+                  controls.transferCtrl.mousedown(e, "move",  store.currComp)
+                }               
               }
             }}>
             {slots.default?.()}

+ 8 - 4
src/modules/editor/controllers/TransferCtrl/index.ts

@@ -43,15 +43,19 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
     this.observe();
   }
 
-  mousedown(e: MouseEvent, type: keyof typeof transforms) {
-    const { currComp } = this.store;
+  mousedown(e: MouseEvent, type: keyof typeof transforms, currComp?: any) {
+    if (!currComp) {
+      currComp =  this.store.currComp;
+    }
+    this.currComp = currComp;
+    this.compEl = currComp.$el;
     this.transEvent = {
       startX: e.clientX,
       startY: e.clientY,
       offsetX: 0,
       offsetY: 0,
-      width: currComp.layout.size?.[0] || this.compEl.clientWidth * 2,
-      height: currComp.layout.size?.[1] || this.compEl.clientHeight * 2,
+      width: currComp.layout.size?.[0] || currComp.$el.clientWidth * 2,
+      height: currComp.layout.size?.[1] || currComp.$el.clientHeight * 2,
     };
     this.currTransfer = this.transforms[type]();
     document.addEventListener("mousemove", this.mousemove);