فهرست منبع

吸附icon功能

haojianlong 4 سال پیش
والد
کامیت
326dba29b5
1فایلهای تغییر یافته به همراه30 افزوده شده و 9 حذف شده
  1. 30 9
      src/components/mapClass/EditScence.ts

+ 30 - 9
src/components/mapClass/EditScence.ts

@@ -1073,6 +1073,17 @@ export class EditScence extends SGraphScene {
             this.highLight.visible = false;
             this.absorbSpace(event);
         }
+        if (this.grabItem){
+            if (this.grabItem instanceof TipelineItem) {
+                const anc = this.clickIsAnchor(event);
+                if (anc) {
+                    const p = anc.mapToScene(0, 0)
+                    event.x = p.x;
+                    event.y = p.y;
+                    return this.grabItem.onMouseMove(event);
+                }
+            }
+        }
         return super.onMouseMove(event)
     }
 
@@ -1481,7 +1492,15 @@ export class EditScence extends SGraphScene {
             if (image.anchorList && image.anchorList.length) {
                 let scenePoint = image.mapFromScene(event.x, event.y);
                 if (image.contains(scenePoint.x, scenePoint.y)) {
-                    image.anchorList.forEach(anchor => {
+                    // image.anchorList.forEach(anchor => {
+                    //     let anchorPoint = anchor.mapToScene(0, 0);
+                    //     let dis = SMathUtil.pointDistance(
+                    //         event.x,
+                    //         event.y,
+                    //         anchorPoint.x,
+                    //         anchorPoint.y
+                    //     );
+                        let anchor = image.anchorList[0]
                         let anchorPoint = anchor.mapToScene(0, 0);
                         let dis = SMathUtil.pointDistance(
                             event.x,
@@ -1489,21 +1508,23 @@ export class EditScence extends SGraphScene {
                             anchorPoint.x,
                             anchorPoint.y
                         );
-                        // let dis = SMathUtil.pointDistance(
-                        //     scenePoint.x,
-                        //     scenePoint.y,
-                        //     anchorPoint.x,
-                        //     anchorPoint.y
-                        // );
                         console.log(dis)
                         if (len < 0) {
-                            len = anchor.sceneDis;
+                            minAnchor = anchor;
+                            len = dis;
                         }
                         if (dis < len) {
                             minAnchor = anchor;
                             len = dis;
                         }
-                    })
+                        // if (len < 0) {
+                        //     len = anchor.sceneDis;
+                        // }
+                        // if (dis < len) {
+                        //     minAnchor = anchor;
+                        //     len = dis;
+                        // }
+                    // })
                 }
             }
         })