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,
|
connectionRadius,
|
||||||
connectOnClick,
|
connectOnClick,
|
||||||
connectionClickStartHandle,
|
connectionClickStartHandle,
|
||||||
connectionStatus,
|
|
||||||
nodesConnectable,
|
nodesConnectable,
|
||||||
defaultEdgeOptions,
|
defaultEdgeOptions,
|
||||||
autoPanOnConnect,
|
autoPanOnConnect,
|
||||||
@@ -114,8 +113,6 @@ export default function useHandle({
|
|||||||
event,
|
event,
|
||||||
)
|
)
|
||||||
|
|
||||||
connectionStatus.value = null
|
|
||||||
|
|
||||||
emits.connectStart({ event, nodeId, handleId, handleType })
|
emits.connectStart({ event, nodeId, handleId, handleType })
|
||||||
|
|
||||||
function onPointerMove(event: MouseEvent | TouchEvent) {
|
function onPointerMove(event: MouseEvent | TouchEvent) {
|
||||||
@@ -155,10 +152,9 @@ export default function useHandle({
|
|||||||
viewport.value,
|
viewport.value,
|
||||||
)
|
)
|
||||||
: connectionPosition,
|
: connectionPosition,
|
||||||
|
getConnectionStatus(!!prevClosestHandle, result.isValid),
|
||||||
)
|
)
|
||||||
|
|
||||||
connectionStatus.value = getConnectionStatus(!!prevClosestHandle, isValid)
|
|
||||||
|
|
||||||
if (!prevClosestHandle) return resetRecentHandle(prevActiveHandle)
|
if (!prevClosestHandle) return resetRecentHandle(prevActiveHandle)
|
||||||
|
|
||||||
connection = result.connection
|
connection = result.connection
|
||||||
|
|||||||
@@ -429,6 +429,8 @@ export function useActions(state: State, getters: ComputedGetters): Actions {
|
|||||||
state.connectionStartHandle = startHandle
|
state.connectionStartHandle = startHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.connectionStatus = null
|
||||||
|
|
||||||
if (position) state.connectionPosition = position
|
if (position) state.connectionPosition = position
|
||||||
|
|
||||||
state.hooks.connectStart.trigger({
|
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.connectionPosition = position
|
||||||
|
state.connectionStatus = status
|
||||||
}
|
}
|
||||||
|
|
||||||
const endConnection: Actions['endConnection'] = (event, isClick) => {
|
const endConnection: Actions['endConnection'] = (event, isClick) => {
|
||||||
state.connectionPosition = { x: NaN, y: NaN }
|
state.connectionPosition = { x: NaN, y: NaN }
|
||||||
|
state.connectionStatus = null
|
||||||
|
|
||||||
if (isClick) {
|
if (isClick) {
|
||||||
state.connectionClickStartHandle = null
|
state.connectionClickStartHandle = null
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ export interface Actions extends ViewportFunctions {
|
|||||||
/** start a connection */
|
/** start a connection */
|
||||||
startConnection: (startHandle: StartHandle, position?: XYPosition, event?: MouseEvent | TouchEvent, isClick?: boolean) => void
|
startConnection: (startHandle: StartHandle, position?: XYPosition, event?: MouseEvent | TouchEvent, isClick?: boolean) => void
|
||||||
/** update connection position */
|
/** update connection position */
|
||||||
updateConnection: (position: XYPosition) => void
|
updateConnection: (position: XYPosition, status?: ConnectionStatus | null) => void
|
||||||
/** end (or cancel) a connection */
|
/** end (or cancel) a connection */
|
||||||
endConnection: (event?: MouseEvent | TouchEvent, isClick?: boolean) => void
|
endConnection: (event?: MouseEvent | TouchEvent, isClick?: boolean) => void
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user