11import { computed , defineComponent , h , inject } from 'vue'
22import type { HandleElement } from '../../types'
33import { ConnectionLineType , ConnectionMode , Position } from '../../types'
4- import { getHandlePosition , getMarkerId } from '../../utils'
4+ import { getHandlePosition , getMarkerId , oppositePosition } from '../../utils'
55import { useVueFlow } from '../../composables'
66import { Slots } from '../../context'
77import { getBezierPath , getSimpleBezierPath , getSmoothStepPath } from '../Edges/utils'
88
9- const oppositePosition = {
10- [ Position . Left ] : Position . Right ,
11- [ Position . Right ] : Position . Left ,
12- [ Position . Top ] : Position . Bottom ,
13- [ Position . Bottom ] : Position . Top ,
14- }
15-
169const ConnectionLine = defineComponent ( {
1710 name : 'ConnectionLine' ,
1811 compatConfig : { MODE : 3 } ,
@@ -57,7 +50,7 @@ const ConnectionLine = defineComponent({
5750 return null
5851 }
5952
60- const startHandleId = connectionStartHandle . value . handleId
53+ const startHandleId = connectionStartHandle . value . id
6154
6255 const handleType = connectionStartHandle . value . type
6356
@@ -78,18 +71,18 @@ const ConnectionLine = defineComponent({
7871 const { x : fromX , y : fromY } = getHandlePosition ( fromNode . value , fromHandle , fromPosition )
7972
8073 let toHandle : HandleElement | null = null
81- if ( toNode . value && connectionEndHandle . value ?. handleId ) {
74+ if ( toNode . value ) {
8275 // if connection mode is strict, we only look for handles of the opposite type
8376 if ( connectionMode . value === ConnectionMode . Strict ) {
8477 toHandle =
8578 toNode . value . handleBounds [ handleType === 'source' ? 'target' : 'source' ] ?. find (
86- ( d ) => d . id === connectionEndHandle . value ?. handleId ,
79+ ( d ) => d . id === connectionEndHandle . value ?. id ,
8780 ) || null
8881 } else {
8982 // if connection mode is loose, look for the handle in both source and target bounds
9083 toHandle =
9184 [ ...( toNode . value . handleBounds . source || [ ] ) , ...( toNode . value . handleBounds . target || [ ] ) ] ?. find (
92- ( d ) => d . id === connectionEndHandle . value ?. handleId ,
85+ ( d ) => d . id === connectionEndHandle . value ?. id ,
9386 ) || null
9487 }
9588 }
0 commit comments