Skip to content

Commit 940b08e

Browse files
committed
chore(docs): update useHandle docs
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent 564d593 commit 940b08e

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

docs/src/guide/composables.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ console.log(nodeId.value) // '1'
149149

150150
## [useHandle](/typedocs/functions/useHandle)
151151

152-
Instead of using the Handle component you can use the useHandle composable to create your own custom nodes. `useHandle`
153-
provides you with a mouseDown- and click-handler functions that you can apply to the element you want to use as a
152+
Instead of using the Handle component you can use the useHandle composable to create your own custom nodes.
153+
154+
`useHandle`
155+
provides you with a pointerDown- and click-handler functions that you can apply to the element you want to use as a
154156
node-handle.
155157

156158
This is how the default handle component is built:
@@ -167,40 +169,45 @@ const props = withDefaults(defineProps<HandleProps>(), {
167169
connectable: true,
168170
})
169171
170-
const { id, hooks, connectionStartHandle } = useVueFlow()
171172
const nodeId = inject(NodeId, '')
172173
173-
const { onMouseDown, onClick } = useHandle()
174-
const onMouseDownHandler = (event: MouseEvent) =>
175-
onMouseDown(event, props.id ?? null, nodeId, props.type === 'target', props.isValidConnection, undefined, (connection) =>
176-
hooks.value.connect.trigger(connection),
177-
)
178-
const onClickHandler = (event: MouseEvent) => onClick(event, props.id ?? null, nodeId, props.type, props.isValidConnection)
174+
const { id, hooks, connectionStartHandle } = useVueFlow()
175+
176+
const { handlePointerDown, handleClick } = useHandle({
177+
nodeId,
178+
handleId: props.id,
179+
isValidConnection: props.isValidConnection,
180+
type: props.type,
181+
})
182+
183+
const onMouseDownHandler = (event: MouseEvent) => handlePointerDown(event)
184+
185+
const onClickHandler = (event: MouseEvent) => handleClick(event)
179186
</script>
180187
181188
<script lang="ts">
182189
export default {
183-
name: 'Handle',
190+
name: 'CustomHandle',
184191
}
185192
</script>
186193
187194
<template>
188195
<div
189-
:data-handleid="props.id"
196+
:data-handleid="id"
190197
:data-nodeid="nodeId"
191-
:data-handlepos="props.position"
198+
:data-handlepos="position"
192199
class="vue-flow__handle nodrag"
193200
:class="[
194-
`vue-flow__handle-${props.position}`,
201+
`vue-flow__handle-${position}`,
195202
`vue-flow__handle-${id}`,
196203
{
197-
source: props.type !== 'target',
198-
target: props.type === 'target',
199-
connectable: props.connectable,
204+
source: type !== 'target',
205+
target: type === 'target',
206+
connectable: connectable,
200207
connecting:
201208
connectionStartHandle?.nodeId === nodeId &&
202-
connectionStartHandle?.handleId === props.id &&
203-
connectionStartHandle?.type === props.type,
209+
connectionStartHandle?.handleId === id &&
210+
connectionStartHandle?.type === type,
204211
},
205212
]"
206213
@mousedown="onMouseDownHandler"

0 commit comments

Comments
 (0)