feat(core): add clickConnectStart & clickConnectEnd events

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-04-03 08:53:33 +02:00
committed by Braks
parent 707aaef535
commit 5a50cfd90b
4 changed files with 21 additions and 4 deletions
+8 -3
View File
@@ -184,9 +184,10 @@ export default function useHandle({
function onPointerUp(event: MouseTouchEvent) {
if ((prevClosestHandle || handleDomNode) && connection && isValid) {
if (!onEdgeUpdate) {
emits.connect(connection)
} else {
onEdgeUpdate(event, connection)
emits.connect(connection)
} else {
onEdgeUpdate(event, connection)
}
}
}
@@ -227,6 +228,8 @@ export default function useHandle({
}
if (!connectionClickStartHandle.value) {
emits.clickConnectStart({ event, nodeId, handleId })
startConnection({ nodeId: unref(nodeId), type: unref(type), handleId: unref(handleId) }, undefined, event, true)
} else {
let isValidConnectionHandler = isValidConnection || isValidConnectionProp.value || alwaysValid
@@ -266,6 +269,8 @@ export default function useHandle({
emits.connect(connection)
}
emits.clickConnectEnd(event)
endConnection(event, true)
}
}
@@ -75,6 +75,13 @@ const emit = defineEmits<{
} & OnConnectStartParams,
): void
(event: 'connectEnd', connectionEvent?: MouseEvent): void
(
event: 'clickConnectStart',
connectionEvent: {
event?: MouseEvent
} & OnConnectStartParams,
): void
(event: 'clickConnectEnd', connectionEvent?: MouseEvent): void
(event: 'moveStart', moveEvent: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }): void
(event: 'move', moveEvent: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }): void
(event: 'moveEnd', moveEvent: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }): void
+2 -1
View File
@@ -24,6 +24,8 @@ export function createHooks(): FlowHooks {
connect: createExtendedEventHook(),
connectStart: createExtendedEventHook(),
connectEnd: createExtendedEventHook(),
clickConnectStart: createExtendedEventHook(),
clickConnectEnd: createExtendedEventHook(),
paneReady: createExtendedEventHook(),
move: createExtendedEventHook(),
moveStart: createExtendedEventHook(),
@@ -54,7 +56,6 @@ export function createHooks(): FlowHooks {
edgeUpdateEnd: createExtendedEventHook(),
updateNodeInternals: createExtendedEventHook(),
error: createExtendedEventHook((err) => warn(err.message)),
}
}
export function useHooks(emit: (...args: any[]) => void, hooks: Ref<FlowHooks>) {
+4
View File
@@ -58,6 +58,10 @@ export interface FlowEvents {
event?: MouseEvent | TouchEvent
} & OnConnectStartParams
connectEnd: MouseEvent | TouchEvent | undefined
clickConnectStart: {
event?: MouseEvent | TouchEvent
} & OnConnectStartParams
clickConnectEnd: MouseEvent | TouchEvent | undefined
paneReady: VueFlowStore
move: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }
moveStart: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }