File tree Expand file tree Collapse file tree 5 files changed +18
-9
lines changed
components/ConnectionLine Expand file tree Collapse file tree 5 files changed +18
-9
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @vue-flow/core " : minor
3
+ ---
4
+
5
+ Use correct end handle position in connection line component and store handle positions during connections.
Original file line number Diff line number Diff line change @@ -93,8 +93,7 @@ const ConnectionLine = defineComponent({
93
93
}
94
94
}
95
95
96
- // we assume the target position is opposite to the source position
97
- const toPosition = fromPosition ? oppositePosition [ fromPosition ] : null
96
+ const toPosition = connectionEndHandle . value ?. position ?? ( fromPosition ? oppositePosition [ fromPosition ] : null )
98
97
99
98
if ( ! fromPosition || ! toPosition ) {
100
99
return null
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
rendererPointToPoint ,
16
16
resetRecentHandle ,
17
17
} from '../utils'
18
+ import { Position } from '../types'
18
19
import { useVueFlow } from './useVueFlow'
19
20
20
21
export interface UseHandleProps {
@@ -129,6 +130,7 @@ export function useHandle({
129
130
nodeId : toValue ( nodeId ) ,
130
131
handleId : toValue ( handleId ) ,
131
132
type : handleType ,
133
+ position : ( clickedHandle ?. getAttribute ( 'data-handlepos' ) as Position ) || Position . Top ,
132
134
} ,
133
135
{
134
136
x : x - containerBounds . left ,
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ export interface ValidHandleResult {
26
26
export interface ConnectingHandle {
27
27
nodeId : string
28
28
type : HandleType
29
- handleId : string | null
29
+ handleId ?: string | null
30
+ position ?: Position | null
30
31
}
31
32
32
33
/** A valid connection function can determine if an attempted connection is valid or not, i.e. abort creating a new edge */
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
8
8
GraphNode ,
9
9
HandleType ,
10
10
NodeHandleBounds ,
11
+ Position ,
11
12
ValidConnectionFunc ,
12
13
ValidHandleResult ,
13
14
XYPosition ,
@@ -192,19 +193,20 @@ export function isValidHandle(
192
193
? ( isTarget && handleType === 'source' ) || ( ! isTarget && handleType === 'target' )
193
194
: handleNodeId !== fromNodeId || handleId !== fromHandleId )
194
195
195
- result . endHandle = {
196
- nodeId : handleNodeId ,
197
- handleId,
198
- type : handleType as HandleType ,
199
- }
200
-
201
196
if ( isValid ) {
202
197
result . isValid = isValidConnection ( connection , {
203
198
edges,
204
199
nodes,
205
200
sourceNode : findNode ( connection . source ) ! ,
206
201
targetNode : findNode ( connection . target ) ! ,
207
202
} )
203
+
204
+ result . endHandle = {
205
+ nodeId : handleNodeId ,
206
+ handleId,
207
+ type : handleType as HandleType ,
208
+ position : result . isValid ? ( handleToCheck . getAttribute ( 'data-handlepos' ) as Position ) : null ,
209
+ }
208
210
}
209
211
}
210
212
You can’t perform that action at this time.
0 commit comments