liwei há 1 ano atrás
pai
commit
c36adb6edf

+ 7 - 5
src/modules/editor/components/CompUI/basicUI/Curve/component.tsx

@@ -81,7 +81,7 @@ function parsePoints( points:number[][],  width:number, height:number) {
     let n = points.length;
     for(let i=0; i<n; i++) {
         const p = points[i]
-
+        
         const x = p[0]*width, y = p[1]*height;
 
           //绘制控制点的位置
@@ -177,10 +177,10 @@ export const Component = defineComponent({
             //判断是否
             console.log("dbclick=>xxxxx", ret);
             if (ret.clicked) {//点击删除
-                points.splice(ret.index, 1);
-                if (points.length < 2) {
+                if (points.length < 3) {
                     return;
                 }
+                points.splice(ret.index, 1);
 
             } else {
                 let next = ret.index + 1;
@@ -218,7 +218,7 @@ export const Component = defineComponent({
                 
                 const isDragingIndex = ret.pIndex;
 
-                const box = controls.selectCtrl.getCurrCardViewPortBox();
+                const box = controls.selectCtrl.getCurrCardBox();
 
                 const mvingPoint = !ret.clickCurve && !ret.clickLine
                 let initControlpLen :number | undefined = undefined;
@@ -229,6 +229,7 @@ export const Component = defineComponent({
 
                     const obj = controls.selectCtrl.objContainer;  
                     const cardX = e.clientX - box.left, cardY =  e.clientY - box.top;
+                    
                     const p = {x: cardX, y:cardY} as any;
                     obj.parent.worldTransform.applyInverse(p, p);
                     obj.parent.updateTransform();
@@ -236,7 +237,8 @@ export const Component = defineComponent({
                     const x = helper.pxToDesignSize(p.x), y =  helper.pxToDesignSize(p.y);
                     const offx = ( x - dragingX) / width;
                     const offy = ( y -  dragingY) / height;
-                    
+                    console.log("offxxxxxxxxxxxx=>", x);
+
                     if (ret.moving) {//移动所有
                         points.forEach((p,i)=>{
                             p[0] = initPoints[i][0] + offx;

+ 10 - 0
src/modules/editor/components/CompUI/basicUI/Curve/index.ts

@@ -30,6 +30,16 @@ export class CompCurveObj extends DesignCompObj<typeof CurveValue> {
     this.compKey = "Curve";
     this.layout.size = [750, 750];
   }
+  fromJson(data:any) {
+    super.fromJson(data);
+
+    console.log("--------------", this.value.points);
+    let hasEmpty = false;
+    this.value.points.forEach(item=>{
+      if (!item) hasEmpty = true;
+    })
+    if (hasEmpty) this.value.points = [];
+  }
 }
 
 export function createComp() {