liwei 1 year ago
parent
commit
3bb2c4ae93

+ 9 - 4
src/modules/editor/module/actions/edit.ts

@@ -10,15 +10,20 @@ export const editActions = EditorModule.action({
   // 通过拖拽添加组件到画布
   async dragCompToDesign(event: MouseEvent, compKey: ICompKeys) {
     await this.actions.addCompToDesign(compKey);
+
+
+
     const cardPoints = this.helper.getPointOffsetWith(
       event,
       this.store.currStreamCard.$el
     );
     const { currComp } = this.store;
-    currComp.translate(
-      375 - (currComp.layout.size?.[0] || 750) / 2,
-      this.helper.pxToDesignSize(cardPoints.y)
-    );
+    let selCtrl = this.controls.selectCtrl
+    selCtrl.selecteObjs([new CompObject(currComp) ])
+    selCtrl.translate(this.helper.designSizeToPx(375 - (currComp.layout.size?.[0] || 750) / 2), cardPoints.y);
+
+    this.helper.extendStreamCard(this.store.currStreamCardId);
+
   },
   // 通过点击添加组件到画布
   async clickCompToDesign(compKey: ICompKeys) {

+ 3 - 2
src/modules/editor/module/helpers/index.ts

@@ -116,6 +116,7 @@ export const helpers = EditorModule.helper({
     const c = compMap[compId];
     const obj = new CompObject(c);
     const bound = obj.getBox();
+    
     return bound;
   },
 
@@ -127,8 +128,8 @@ export const helpers = EditorModule.helper({
       n = childs.length;
     while (n--) {
       const c = childs[n];
-      const b = this.helper.getCardCompBound(c);
-      maxH = Math.max(maxH, b.y + b.h);
+      const aabb = this.helper.getCardCompBound(c);
+      maxH = Math.max(maxH, aabb.y + aabb.h);
     }
     maxH = this.helper.pxToDesignSize(maxH) + 10;
     const cardH = card.layout.size?.[1] as number;