import type { MaybeElementRef, MaybeRefOrGetter } from '../../types/shared/utils'; export type SwipeDirection = 'left' | 'right' | 'top' | 'bottom'; export interface SwipePressState { size: number; /** The pointerdown event that opened the gesture. */ event: PointerEvent; } export interface SwipeFollowState { /** Movement since the previous event along the active axis (px). */ delta: number; /** Signed velocity (px / ms) since the previous event along the active axis. */ velocity: number; /** `displacement / containerSize` signed ratio, typically in the range of -1 to 1. */ offset: number; /** Signed displacement from the start point along the active axis (px). */ displacement: number; /** The pointermove event that produced this sample. */ event: PointerEvent; } export interface SwipeReleaseState { /** Whether the gesture qualified as a successful swipe (by velocity or distance). */ swiped: boolean; /** Physical swipe direction. `undefined` when `swiped` is `false`. */ direction?: SwipeDirection; /** Signed displacement at release along the active axis (px). */ displacement: number; /** Signed velocity at release (px / ms). */ velocity: number; /** Whether the gesture stayed on the target axis from the moment it was locked. */ axisLocked: boolean; /** The pointerup or pointercancel event that ended the gesture. */ event: PointerEvent; } export interface SwipeTapState { /** The pointerup event that ended the interaction. */ event: PointerEvent; /** * The pointerdown event that started it. A release that never became a pan can * land on a different element, so hit-testing should use what the user pressed. */ startEvent: PointerEvent | null; /** * `true` when `beforeStart` discarded the gesture, `false` when the pointer * simply never travelled far enough to be recognized. */ vetoed: boolean; } export interface SwipeGestureOptions { enabled?: MaybeRefOrGetter; /** CSS selector for the drag handle element within the container. */ handleSelector?: string; /** Swipe axis. Reactive; accepts a ref or getter. */ axis?: MaybeRefOrGetter<'horizontal' | 'vertical'>; /** Minimum movement (px) before locking the gesture axis. */ axisLockThreshold?: number; /** Main-axis movement must be at least this multiple of cross-axis movement. */ axisLockRatio?: number; /** Minimum swipe distance (px) before movement events start. */ swipeThreshold?: number; /** Fraction of the container size the finger must travel for a slow-drag swipe. */ distanceThreshold?: number; /** Minimum absolute velocity (px / ms) for a quick-flick swipe. */ velocityThreshold?: number; /** * Gate evaluated once the gesture is recognized. Resolving `false` discards the * gesture: `onFollow` never fires and the release is reported through `onTap` * with `vetoed: true`. Movement arriving while a promise is pending is dropped, * and a release inside that window waits for the verdict. */ beforeStart?: (state: SwipePressState) => boolean | Promise; onPress?: (state: SwipePressState) => void; onFollow?: (state: SwipeFollowState) => void; /** * Receives the raw release metrics. `swiped` and `direction` follow * `distanceThreshold` / `velocityThreshold` against the container size; consumers * that measure against something else decide from `displacement` themselves. */ onRelease?: (state: SwipeReleaseState) => void; /** * Called on release when no swipe was ever recognized: the pointer travelled less * than `swipeThreshold`, or `beforeStart` discarded it. */ onTap?: (state: SwipeTapState) => void; } export declare function useSwipeGesture(containerRef: MaybeElementRef, options?: SwipeGestureOptions): { stop: () => void; };