@@ -3,11 +3,11 @@ import LogicFlow, {
3
3
twoPointDistance ,
4
4
BaseNodeModel ,
5
5
BaseEdgeModel ,
6
- Point ,
7
6
} from '@logicflow/core'
8
7
import { assign , isEmpty , isEqual , isNil , isFinite , reduce } from 'lodash-es'
9
8
10
9
import AnchorConfig = Model . AnchorConfig
10
+ import Point = LogicFlow . Point
11
11
12
12
export type ProximityConnectProps = {
13
13
enable : boolean
@@ -104,7 +104,9 @@ export class ProximityConnect {
104
104
this . virtualEdge = undefined
105
105
}
106
106
}
107
- this . findClosestAnchorOfNode ( this . currentNode , nodes )
107
+ if ( this . currentNode ) {
108
+ this . findClosestAnchorOfNode ( this . currentNode , nodes )
109
+ }
108
110
if ( this . currentDistance < this . thresholdDistance ) {
109
111
this . addVirtualEdge ( )
110
112
}
@@ -127,7 +129,7 @@ export class ProximityConnect {
127
129
y : clientY ,
128
130
} )
129
131
if ( isNil ( x ) || isNil ( y ) ) return
130
- const currentPoint = { x, y }
132
+ const currentPoint : Point = { x, y }
131
133
const { nodes } = graphModel
132
134
// 判断当前是否有虚拟连线,有的话判断两点距离是否超过阈值,超过的话删除连线
133
135
if ( ! isNil ( this . virtualEdge ) ) {
@@ -227,7 +229,7 @@ export class ProximityConnect {
227
229
anchorAllowConnect (
228
230
node : BaseNodeModel ,
229
231
anchor : AnchorConfig ,
230
- draggingAnchor : AnchorConfig ,
232
+ draggingAnchor : AnchorConfig | undefined ,
231
233
) {
232
234
const { currentNode } = this
233
235
if ( ! currentNode ) return
0 commit comments