Bläddra i källkod

拓扑图 移动item 关系线跟随变化 ,并保持折线状态

haojianlong 5 år sedan
förälder
incheckning
c6db2bed6b
3 ändrade filer med 20 tillägg och 6 borttagningar
  1. 1 1
      package.json
  2. 3 3
      src/TopoScene.ts
  3. 16 2
      src/items/RelationItem.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/topology",
-    "version": "1.0.62",
+    "version": "1.0.65",
     "description": "上格云拓扑图引擎",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 3 - 3
src/TopoScene.ts

@@ -200,9 +200,9 @@ export class TopoScene extends SGraphyScene {
             } else {
                 console.log("未点击锚点");
                 // 点击的不是锚点,处理点击点与
-                // if (this.grabItem) {
-                //     this.grabItem.onMouseDown(event);
-                // }
+                if (this.relatItem) {
+                    this.relatItem.onMouseDown(event);
+                }
             }
         } else {
             super.onMouseDown(event);

+ 16 - 2
src/items/RelationItem.ts

@@ -113,6 +113,7 @@ export class RelationItem extends BaseRelationItem {
      */
     onMouseMove(event: SMouseEvent): boolean {
         if (this.pointList.length) {
+            console.log("dowm");
             this.lastPointList = [
                 this.pointList[this.pointList.length - 1],
                 this.getPoint(
@@ -157,13 +158,26 @@ export class RelationItem extends BaseRelationItem {
                     this.Anchor1.X,
                     this.Anchor1.Y
                 );
-                console.log(this.pointList[0]);
+                if (this.pointList[1] && this.pointList[2]) {
+                    this.pointList[1] = this.getPoint(
+                        this.pointList[0],
+                        this.pointList[2]
+                    );
+                }
             }
             if (this.Anchor2) {
                 this.pointList[
                     this.pointList.length - 1
                 ] = this.Anchor2.mapToScene(this.Anchor2.X, this.Anchor2.Y);
-                console.log(this.pointList);
+                if (
+                    this.pointList[this.pointList.length - 1] &&
+                    this.pointList[this.pointList.length - 3]
+                ) {
+                    this.pointList[this.pointList.length - 2] = this.getPoint(
+                        this.pointList[this.pointList.length - 1],
+                        this.pointList[this.pointList.length - 3]
+                    );
+                }
             }
         }
         this.update();