Skip to content

Commit 6a2b7e5

Browse files
authored
fix(core): use whole handle for snapping area (#1843)
* chore(changeset): add * fix(core): use whole handle for snapping area Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent dc66c85 commit 6a2b7e5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

.changeset/mighty-glasses-impress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Use whole handle area for snapping.

packages/core/src/composables/useHandle.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export function useHandle({
163163
id: toValue(handleId),
164164
type: handleType,
165165
position: (clickedHandle?.getAttribute('data-handlepos') as Position) || Position.Top,
166+
...connectionPosition,
166167
},
167168
{
168169
x: x - containerBounds.left,
@@ -217,8 +218,8 @@ export function useHandle({
217218
...previousConnection,
218219
isValid,
219220
to:
220-
closestHandle && isValid
221-
? rendererPointToPoint({ x: closestHandle.x, y: closestHandle.y }, viewport.value)
221+
result.toHandle && isValid
222+
? rendererPointToPoint({ x: result.toHandle.x, y: result.toHandle.y }, viewport.value)
222223
: connectionPosition,
223224
toHandle: result.toHandle,
224225
toPosition: isValid && result.toHandle ? result.toHandle.position : oppositePosition[fromHandle.position],
@@ -325,7 +326,13 @@ export function useHandle({
325326
emits.clickConnectStart({ event, nodeId: toValue(nodeId), handleId: toValue(handleId) })
326327

327328
startConnection(
328-
{ nodeId: toValue(nodeId), type: toValue(type), id: toValue(handleId), position: Position.Top },
329+
{
330+
nodeId: toValue(nodeId),
331+
type: toValue(type),
332+
id: toValue(handleId),
333+
position: Position.Top,
334+
...getEventPosition(event),
335+
},
329336
undefined,
330337
true,
331338
)
@@ -355,10 +362,11 @@ export function useHandle({
355362
id: toValue(handleId),
356363
type: toValue(type),
357364
position: Position.Top,
365+
...getEventPosition(event),
358366
},
359367
connectionMode: connectionMode.value,
360368
fromNodeId: connectionClickStartHandle.value.nodeId,
361-
fromHandleId: connectionClickStartHandle.value.id || null,
369+
fromHandleId: connectionClickStartHandle.value.id ?? null,
362370
fromType: connectionClickStartHandle.value.type,
363371
isValidConnection: isValidConnectionHandler,
364372
doc,

packages/core/src/types/handle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface ConnectionHandle extends XYPosition {
1919
nodeId: string
2020
}
2121

22-
export interface ConnectingHandle {
22+
export interface ConnectingHandle extends XYPosition {
2323
nodeId: string
2424
type: HandleType
2525
id?: string | null

0 commit comments

Comments
 (0)