Skip to content

Commit 619f4bf

Browse files
committed
refactor(core): cleanup useHandle and set status on actions
Signed-off-by: braks <[email protected]>
1 parent 3d958df commit 619f4bf

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/core/src/composables/useHandle.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export default function useHandle({
3333
connectionRadius,
3434
connectOnClick,
3535
connectionClickStartHandle,
36-
connectionStatus,
3736
nodesConnectable,
3837
defaultEdgeOptions,
3938
autoPanOnConnect,
@@ -114,8 +113,6 @@ export default function useHandle({
114113
event,
115114
)
116115

117-
connectionStatus.value = null
118-
119116
emits.connectStart({ event, nodeId, handleId, handleType })
120117

121118
function onPointerMove(event: MouseEvent | TouchEvent) {
@@ -155,10 +152,9 @@ export default function useHandle({
155152
viewport.value,
156153
)
157154
: connectionPosition,
155+
getConnectionStatus(!!prevClosestHandle, result.isValid),
158156
)
159157

160-
connectionStatus.value = getConnectionStatus(!!prevClosestHandle, isValid)
161-
162158
if (!prevClosestHandle) return resetRecentHandle(prevActiveHandle)
163159

164160
connection = result.connection

packages/core/src/store/actions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ export function useActions(state: State, getters: ComputedGetters): Actions {
429429
state.connectionStartHandle = startHandle
430430
}
431431

432+
state.connectionStatus = null
433+
432434
if (position) state.connectionPosition = position
433435

434436
state.hooks.connectStart.trigger({
@@ -439,12 +441,14 @@ export function useActions(state: State, getters: ComputedGetters): Actions {
439441
})
440442
}
441443

442-
const updateConnection: Actions['updateConnection'] = (position) => {
444+
const updateConnection: Actions['updateConnection'] = (position, status = null) => {
443445
state.connectionPosition = position
446+
state.connectionStatus = status
444447
}
445448

446449
const endConnection: Actions['endConnection'] = (event, isClick) => {
447450
state.connectionPosition = { x: NaN, y: NaN }
451+
state.connectionStatus = null
448452

449453
if (isClick) {
450454
state.connectionClickStartHandle = null

packages/core/src/types/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export interface Actions extends ViewportFunctions {
248248
/** start a connection */
249249
startConnection: (startHandle: StartHandle, position?: XYPosition, event?: MouseEvent | TouchEvent, isClick?: boolean) => void
250250
/** update connection position */
251-
updateConnection: (position: XYPosition) => void
251+
updateConnection: (position: XYPosition, status?: ConnectionStatus | null) => void
252252
/** end (or cancel) a connection */
253253
endConnection: (event?: MouseEvent | TouchEvent, isClick?: boolean) => void
254254

0 commit comments

Comments
 (0)