refactor(core): calculate correct handle pos in handle lookup (#1494)

* refactor(core): use `getHandlePosition` to calculate handle pos

* chore(changeset): add
This commit is contained in:
Braks
2024-07-01 09:44:55 +02:00
parent e435485b77
commit 09e222124c
5 changed files with 32 additions and 34 deletions
+5 -3
View File
@@ -12,7 +12,7 @@ import type {
ValidHandleResult,
XYPosition,
} from '../types'
import { getEventPosition } from '.'
import { getEventPosition, getHandlePosition } from '.'
export interface ConnectionHandle extends XYPosition, Dimensions {
id: string | null
@@ -43,12 +43,14 @@ export function getHandles(
): ConnectionHandle[] {
return (handleBounds[type] || []).reduce<ConnectionHandle[]>((res, h) => {
if (`${node.id}-${h.id}-${type}` !== currentHandle) {
const handlePosition = getHandlePosition(h.position, node, h)
res.push({
id: h.id || null,
type,
nodeId: node.id,
x: (node.computedPosition?.x ?? 0) + h.x + h.width / 2,
y: (node.computedPosition?.y ?? 0) + h.y + h.height / 2,
x: handlePosition.x,
y: handlePosition.y,
width: h.width,
height: h.height,
})