Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/usePointerSwipe.md
1---2category: Sensors3---45# usePointerSwipe67Reactive swipe detection based on [PointerEvents](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent).89## Usage1011```vue12<script setup lang="ts">13import { usePointerSwipe } from '@vueuse/core'14import { useTemplateRef } from 'vue'1516const el = useTemplateRef('el')17const { isSwiping, direction } = usePointerSwipe(el)18</script>1920<template>21<div ref="el">22Swipe here23</div>24</template>25```2627## Type Declarations2829```ts30export interface UsePointerSwipeOptions {31/**32* @default 5033*/34threshold?: number35/**36* Callback on swipe start.37*/38onSwipeStart?: (e: PointerEvent) => void39/**40* Callback on swipe move.41*/42onSwipe?: (e: PointerEvent) => void43/**44* Callback on swipe end.45*/46onSwipeEnd?: (e: PointerEvent, direction: UseSwipeDirection) => void47/**48* Pointer types to listen to.49*50* @default ['mouse', 'touch', 'pen']51*/52pointerTypes?: PointerType[]53/**54* Disable text selection on swipe.55*56* @default false57*/58disableTextSelect?: boolean59}60export interface UsePointerSwipeReturn {61readonly isSwiping: ShallowRef<boolean>62direction: Readonly<ShallowRef<UseSwipeDirection>>63readonly posStart: Position64readonly posEnd: Position65distanceX: Readonly<ComputedRef<number>>66distanceY: Readonly<ComputedRef<number>>67stop: () => void68}69/**70* Reactive swipe detection based on PointerEvents.71*72* @see https://vueuse.org/usePointerSwipe73* @param target74* @param options75*/76export declare function usePointerSwipe(77target: MaybeRefOrGetter<HTMLElement | null | undefined>,78options?: UsePointerSwipeOptions,79): UsePointerSwipeReturn80```81