chore(core): cleanup handle utils (#1497)

This commit is contained in:
Braks
2024-07-01 09:44:55 +02:00
parent 09e222124c
commit 8454dca6d4
5 changed files with 30 additions and 57 deletions
@@ -74,7 +74,7 @@ const ConnectionLine = defineComponent({
const fromHandle = (startHandleId ? handleBounds.find((d) => d.id === startHandleId) : handleBounds[0]) ?? null
const fromPosition = fromHandle?.position || Position.Top
const { x: fromX, y: fromY } = getHandlePosition(fromPosition, fromNode.value, fromHandle)
const { x: fromX, y: fromY } = getHandlePosition(fromNode.value, fromHandle, fromPosition)
let toHandle: HandleElement | null = null
if (toNode.value && connectionEndHandle.value?.handleId) {
@@ -8,8 +8,8 @@ import {
ErrorCode,
VueFlowError,
elementSelectionKeys,
getEdgePositions,
getHandle,
getHandlePosition,
getMarkerId,
} from '../../utils'
import EdgeAnchor from './EdgeAnchor'
@@ -160,19 +160,14 @@ const EdgeWrapper = defineComponent({
const targetHandle = getHandle(targetNodeHandles, edge.value.targetHandle)
const sourcePosition = sourceHandle ? sourceHandle.position : Position.Bottom
const sourcePosition = sourceHandle?.position || Position.Bottom
const targetPosition = targetHandle ? targetHandle.position : Position.Top
const targetPosition = targetHandle?.position || Position.Top
const { sourceX, sourceY, targetY, targetX } = getEdgePositions(
sourceNode,
sourceHandle,
sourcePosition,
targetNode,
targetHandle,
targetPosition,
)
const { x: sourceX, y: sourceY } = getHandlePosition(sourceNode, sourceHandle, sourcePosition)
const { x: targetX, y: targetY } = getHandlePosition(targetNode, targetHandle, targetPosition)
// todo: let's avoid writing these here (in v2 we want to remove all of these self-managed refs)
edge.value.sourceX = sourceX
edge.value.sourceY = sourceY
edge.value.targetX = targetX