fix(core,edges): when connection mode is Loose use all handles as connection line source handle

This commit is contained in:
braks
2022-11-13 23:23:09 +01:00
committed by Braks
parent d34cf4bf8f
commit cd4383d00e
@@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { GraphNode, HandleElement } from '../../types' import type { GraphNode, HandleElement } from '../../types'
import { ConnectionLineType, Position } from '../../types' import { ConnectionLineType, ConnectionMode, Position } from '../../types'
import { getMarkerId } from '../../utils' import { getMarkerId } from '../../utils'
const { sourceNode } = defineProps<{ const { sourceNode } = defineProps<{
@@ -9,6 +9,7 @@ const { sourceNode } = defineProps<{
const { const {
getNodes, getNodes,
connectionMode,
connectionStartHandle, connectionStartHandle,
connectionPosition, connectionPosition,
connectionLineType, connectionLineType,
@@ -26,9 +27,11 @@ const nodeId = connectionStartHandle!.nodeId
const type = connectionStartHandle!.type const type = connectionStartHandle!.type
const sourceHandle = const sourceHandle =
handleId && type (connectionMode === ConnectionMode.Strict
? sourceNode.handleBounds[type]?.find((d: HandleElement) => d.id === handleId) ? sourceNode.handleBounds[type]?.find((d: HandleElement) => d.id === handleId)
: type && sourceNode.handleBounds[type ?? 'source']?.[0] : [...(sourceNode.handleBounds.source || []), ...(sourceNode.handleBounds.target || [])]?.find(
(d: HandleElement) => d.id === handleId,
)) || sourceNode.handleBounds[type ?? 'source']?.[0]
const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : sourceNode.dimensions.width / 2 const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : sourceNode.dimensions.width / 2
const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : sourceNode.dimensions.height const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : sourceNode.dimensions.height