Skip to content

Commit

Permalink
feat(useDraggable): support capture option (#2725)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
faga295 and antfu committed Apr 13, 2023
1 parent 8a9dd47 commit 3996d44
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/core/useDraggable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export interface UseDraggableOptions {
*/
stopPropagation?: MaybeRefOrGetter<boolean>

/**
* Whether dispatch events in capturing phase
*
* @default true
*/
capture?: boolean

/**
* Element to attach `pointermove` and `pointerup` events to.
*
Expand Down Expand Up @@ -166,9 +173,10 @@ export function useDraggable(
}

if (isClient) {
useEventListener(draggingHandle, 'pointerdown', start, true)
useEventListener(draggingElement, 'pointermove', move, true)
useEventListener(draggingElement, 'pointerup', end, true)
const config = { capture: options.capture ?? true }
useEventListener(draggingHandle, 'pointerdown', start, config)
useEventListener(draggingElement, 'pointermove', move, config)
useEventListener(draggingElement, 'pointerup', end, config)
}

return {
Expand Down

0 comments on commit 3996d44

Please sign in to comment.