chore: consolidate new foundation and archive v1 (#1495)
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
---
|
||||
category: Sensors
|
||||
---
|
||||
|
||||
# usePointerSwipe
|
||||
|
||||
Reactive swipe detection based on [PointerEvents](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent).
|
||||
|
||||
## Usage
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { usePointerSwipe } from '@vueuse/core';
|
||||
import { useTemplateRef } from 'vue';
|
||||
|
||||
const el = useTemplateRef('el');
|
||||
const { isSwiping, direction } = usePointerSwipe(el);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="el">Swipe here</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
## Type Declarations
|
||||
|
||||
```ts
|
||||
export interface UsePointerSwipeOptions {
|
||||
/**
|
||||
* @default 50
|
||||
*/
|
||||
threshold?: number;
|
||||
/**
|
||||
* Callback on swipe start.
|
||||
*/
|
||||
onSwipeStart?: (e: PointerEvent) => void;
|
||||
/**
|
||||
* Callback on swipe move.
|
||||
*/
|
||||
onSwipe?: (e: PointerEvent) => void;
|
||||
/**
|
||||
* Callback on swipe end.
|
||||
*/
|
||||
onSwipeEnd?: (e: PointerEvent, direction: UseSwipeDirection) => void;
|
||||
/**
|
||||
* Pointer types to listen to.
|
||||
*
|
||||
* @default ['mouse', 'touch', 'pen']
|
||||
*/
|
||||
pointerTypes?: PointerType[];
|
||||
/**
|
||||
* Disable text selection on swipe.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disableTextSelect?: boolean;
|
||||
}
|
||||
export interface UsePointerSwipeReturn {
|
||||
readonly isSwiping: ShallowRef<boolean>;
|
||||
direction: Readonly<ShallowRef<UseSwipeDirection>>;
|
||||
readonly posStart: Position;
|
||||
readonly posEnd: Position;
|
||||
distanceX: Readonly<ComputedRef<number>>;
|
||||
distanceY: Readonly<ComputedRef<number>>;
|
||||
stop: () => void;
|
||||
}
|
||||
/**
|
||||
* Reactive swipe detection based on PointerEvents.
|
||||
*
|
||||
* @see https://vueuse.org/usePointerSwipe
|
||||
* @param target
|
||||
* @param options
|
||||
*/
|
||||
export declare function usePointerSwipe(
|
||||
target: MaybeRefOrGetter<HTMLElement | null | undefined>,
|
||||
options?: UsePointerSwipeOptions,
|
||||
): UsePointerSwipeReturn;
|
||||
```
|
||||
Reference in New Issue
Block a user