@flowgram.ai/free-layout-core 0.2.19 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +12 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/esm/index.js
CHANGED
|
@@ -2751,12 +2751,8 @@ var WorkflowDragService = class {
|
|
|
2751
2751
|
type: "onDrag"
|
|
2752
2752
|
});
|
|
2753
2753
|
this.setLineColor(line, this.linesManager.lineColor.drawing);
|
|
2754
|
-
if (toNode
|
|
2755
|
-
|
|
2756
|
-
const { inputPorts } = portsData;
|
|
2757
|
-
if (inputPorts.length === 1) {
|
|
2758
|
-
toPort = inputPorts[0];
|
|
2759
|
-
}
|
|
2754
|
+
if (toNode) {
|
|
2755
|
+
toPort = this.getNearestPort(toNode, dragPos);
|
|
2760
2756
|
const { hasError } = this.handleDragOnNode(toNode, fromPort, line, toPort, originLine);
|
|
2761
2757
|
lineErrorReset = hasError;
|
|
2762
2758
|
}
|
|
@@ -2864,6 +2860,16 @@ var WorkflowDragService = class {
|
|
|
2864
2860
|
}
|
|
2865
2861
|
};
|
|
2866
2862
|
}
|
|
2863
|
+
/** 获取最近的 port */
|
|
2864
|
+
getNearestPort(node, mousePos) {
|
|
2865
|
+
const portsData = node.getData(WorkflowNodePortsData);
|
|
2866
|
+
const distanceSortedPorts = portsData.inputPorts.sort((a, b) => {
|
|
2867
|
+
const aDistance = Math.abs(mousePos.y - a.point.y);
|
|
2868
|
+
const bDistance = Math.abs(mousePos.y - b.point.y);
|
|
2869
|
+
return aDistance - bDistance;
|
|
2870
|
+
});
|
|
2871
|
+
return distanceSortedPorts[0];
|
|
2872
|
+
}
|
|
2867
2873
|
};
|
|
2868
2874
|
__decorateClass([
|
|
2869
2875
|
inject6(PlaygroundConfigEntity5)
|