refactor(core): cleanup useHandle and set status on actions
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -33,7 +33,6 @@ export default function useHandle({
|
||||
connectionRadius,
|
||||
connectOnClick,
|
||||
connectionClickStartHandle,
|
||||
connectionStatus,
|
||||
nodesConnectable,
|
||||
defaultEdgeOptions,
|
||||
autoPanOnConnect,
|
||||
@@ -114,8 +113,6 @@ export default function useHandle({
|
||||
event,
|
||||
)
|
||||
|
||||
connectionStatus.value = null
|
||||
|
||||
emits.connectStart({ event, nodeId, handleId, handleType })
|
||||
|
||||
function onPointerMove(event: MouseEvent | TouchEvent) {
|
||||
@@ -155,10 +152,9 @@ export default function useHandle({
|
||||
viewport.value,
|
||||
)
|
||||
: connectionPosition,
|
||||
getConnectionStatus(!!prevClosestHandle, result.isValid),
|
||||
)
|
||||
|
||||
connectionStatus.value = getConnectionStatus(!!prevClosestHandle, isValid)
|
||||
|
||||
if (!prevClosestHandle) return resetRecentHandle(prevActiveHandle)
|
||||
|
||||
connection = result.connection
|
||||
|
||||
@@ -429,6 +429,8 @@ export function useActions(state: State, getters: ComputedGetters): Actions {
|
||||
state.connectionStartHandle = startHandle
|
||||
}
|
||||
|
||||
state.connectionStatus = null
|
||||
|
||||
if (position) state.connectionPosition = position
|
||||
|
||||
state.hooks.connectStart.trigger({
|
||||
@@ -439,12 +441,14 @@ export function useActions(state: State, getters: ComputedGetters): Actions {
|
||||
})
|
||||
}
|
||||
|
||||
const updateConnection: Actions['updateConnection'] = (position) => {
|
||||
const updateConnection: Actions['updateConnection'] = (position, status = null) => {
|
||||
state.connectionPosition = position
|
||||
state.connectionStatus = status
|
||||
}
|
||||
|
||||
const endConnection: Actions['endConnection'] = (event, isClick) => {
|
||||
state.connectionPosition = { x: NaN, y: NaN }
|
||||
state.connectionStatus = null
|
||||
|
||||
if (isClick) {
|
||||
state.connectionClickStartHandle = null
|
||||
|
||||
@@ -248,7 +248,7 @@ export interface Actions extends ViewportFunctions {
|
||||
/** start a connection */
|
||||
startConnection: (startHandle: StartHandle, position?: XYPosition, event?: MouseEvent | TouchEvent, isClick?: boolean) => void
|
||||
/** update connection position */
|
||||
updateConnection: (position: XYPosition) => void
|
||||
updateConnection: (position: XYPosition, status?: ConnectionStatus | null) => void
|
||||
/** end (or cancel) a connection */
|
||||
endConnection: (event?: MouseEvent | TouchEvent, isClick?: boolean) => void
|
||||
|
||||
|
||||
Reference in New Issue
Block a user