From b42c1b02deca673c7d0b76ef6211e146f0fc69dd Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 24 Mar 2022 22:18:22 +0100 Subject: [PATCH] feat(handle): Add onClick handler * for touch enabled connections --- src/components/Handle/Handle.vue | 12 +++++-- src/composables/useHandle.ts | 54 +++++++++++++++++++++++++++++--- src/types/connection.ts | 2 +- src/types/flow.ts | 2 +- src/types/handle.ts | 2 +- src/types/node.ts | 5 --- src/utils/edge.ts | 4 +-- 7 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/components/Handle/Handle.vue b/src/components/Handle/Handle.vue index 15013294..95b102a7 100644 --- a/src/components/Handle/Handle.vue +++ b/src/components/Handle/Handle.vue @@ -4,7 +4,7 @@ import { Position } from '../../types' import { NodeId } from '../../context' import type { HandleProps } from '../../types/handle' -const { id, hooks } = useVueFlow() +const { id, hooks, connectionStartHandle } = useVueFlow() const props = withDefaults(defineProps(), { type: 'source', position: 'top' as Position, @@ -13,11 +13,12 @@ const props = withDefaults(defineProps(), { const nodeId = inject(NodeId, '') -const handler = useHandle() +const { onMouseDown, onClick } = useHandle() const onMouseDownHandler = (event: MouseEvent) => - handler(event, props.id, nodeId, props.type === 'target', props.isValidConnection, undefined, (connection) => + onMouseDown(event, props.id ?? null, nodeId, props.type === 'target', props.isValidConnection, undefined, (connection) => hooks.value.connect.trigger(connection), ) +const onClickHandler = (event: MouseEvent) => onClick(event, props.id ?? null, nodeId, props.type, props.isValidConnection)