feat(core): add clickConnectStart & clickConnectEnd events
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -184,9 +184,10 @@ export default function useHandle({
|
|||||||
function onPointerUp(event: MouseTouchEvent) {
|
function onPointerUp(event: MouseTouchEvent) {
|
||||||
if ((prevClosestHandle || handleDomNode) && connection && isValid) {
|
if ((prevClosestHandle || handleDomNode) && connection && isValid) {
|
||||||
if (!onEdgeUpdate) {
|
if (!onEdgeUpdate) {
|
||||||
emits.connect(connection)
|
emits.connect(connection)
|
||||||
} else {
|
} else {
|
||||||
onEdgeUpdate(event, connection)
|
onEdgeUpdate(event, connection)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +228,8 @@ export default function useHandle({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!connectionClickStartHandle.value) {
|
if (!connectionClickStartHandle.value) {
|
||||||
|
emits.clickConnectStart({ event, nodeId, handleId })
|
||||||
|
|
||||||
startConnection({ nodeId: unref(nodeId), type: unref(type), handleId: unref(handleId) }, undefined, event, true)
|
startConnection({ nodeId: unref(nodeId), type: unref(type), handleId: unref(handleId) }, undefined, event, true)
|
||||||
} else {
|
} else {
|
||||||
let isValidConnectionHandler = isValidConnection || isValidConnectionProp.value || alwaysValid
|
let isValidConnectionHandler = isValidConnection || isValidConnectionProp.value || alwaysValid
|
||||||
@@ -266,6 +269,8 @@ export default function useHandle({
|
|||||||
emits.connect(connection)
|
emits.connect(connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emits.clickConnectEnd(event)
|
||||||
|
|
||||||
endConnection(event, true)
|
endConnection(event, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ const emit = defineEmits<{
|
|||||||
} & OnConnectStartParams,
|
} & OnConnectStartParams,
|
||||||
): void
|
): void
|
||||||
(event: 'connectEnd', connectionEvent?: MouseEvent): 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: 'moveStart', moveEvent: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }): void
|
||||||
(event: 'move', 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
|
(event: 'moveEnd', moveEvent: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }): void
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export function createHooks(): FlowHooks {
|
|||||||
connect: createExtendedEventHook(),
|
connect: createExtendedEventHook(),
|
||||||
connectStart: createExtendedEventHook(),
|
connectStart: createExtendedEventHook(),
|
||||||
connectEnd: createExtendedEventHook(),
|
connectEnd: createExtendedEventHook(),
|
||||||
|
clickConnectStart: createExtendedEventHook(),
|
||||||
|
clickConnectEnd: createExtendedEventHook(),
|
||||||
paneReady: createExtendedEventHook(),
|
paneReady: createExtendedEventHook(),
|
||||||
move: createExtendedEventHook(),
|
move: createExtendedEventHook(),
|
||||||
moveStart: createExtendedEventHook(),
|
moveStart: createExtendedEventHook(),
|
||||||
@@ -54,7 +56,6 @@ export function createHooks(): FlowHooks {
|
|||||||
edgeUpdateEnd: createExtendedEventHook(),
|
edgeUpdateEnd: createExtendedEventHook(),
|
||||||
updateNodeInternals: createExtendedEventHook(),
|
updateNodeInternals: createExtendedEventHook(),
|
||||||
error: createExtendedEventHook((err) => warn(err.message)),
|
error: createExtendedEventHook((err) => warn(err.message)),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useHooks(emit: (...args: any[]) => void, hooks: Ref<FlowHooks>) {
|
export function useHooks(emit: (...args: any[]) => void, hooks: Ref<FlowHooks>) {
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ export interface FlowEvents {
|
|||||||
event?: MouseEvent | TouchEvent
|
event?: MouseEvent | TouchEvent
|
||||||
} & OnConnectStartParams
|
} & OnConnectStartParams
|
||||||
connectEnd: MouseEvent | TouchEvent | undefined
|
connectEnd: MouseEvent | TouchEvent | undefined
|
||||||
|
clickConnectStart: {
|
||||||
|
event?: MouseEvent | TouchEvent
|
||||||
|
} & OnConnectStartParams
|
||||||
|
clickConnectEnd: MouseEvent | TouchEvent | undefined
|
||||||
paneReady: VueFlowStore
|
paneReady: VueFlowStore
|
||||||
move: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }
|
move: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }
|
||||||
moveStart: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }
|
moveStart: { event: D3ZoomEvent<HTMLDivElement, any>; flowTransform: ViewportTransform }
|
||||||
|
|||||||
Reference in New Issue
Block a user