UNPKG

vevet

Version:

Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.

129 lines 4.47 kB
import { Module, TModuleOnCallbacksProps } from '../../base'; import { TRequiredProps } from '../../internal/requiredProps'; import { ISwipeState, ISwipeVec2, ISwipeVec3 } from './global'; import { ISwipeCallbacksMap, ISwipeMutableProps, ISwipeStaticProps } from './types'; export * from './types'; export * from './global'; type TC = ISwipeCallbacksMap; type TS = ISwipeStaticProps; type TM = ISwipeMutableProps; /** * Manages swipe interactions: * - Tracks movement and detects direction * - Emits events on start, move, and end * - Supports exponential inertia * - Optional bounds with rubber-band overflow and bounce-back * * Notes: * - Does not transform elements, only computes coordinates. * * [Documentation](https://vevetjs.com/docs/Swipe) * * @group Components */ export declare class Swipe extends Module<TC, TS, TM> { /** * Returns default static properties. */ _getStatic(): TRequiredProps<TS>; /** * Returns default mutable properties. */ _getMutable(): TRequiredProps<TM>; /** Swipe coords */ private _coords; /** Inertia animation */ private _inertia; /** Bounce animation */ private _bounceTm?; /** Styles manager */ private _styles; /** Pointer event manager */ private _pointers; /** If swiping has started */ private _isSwiping; /** If swiping has been aborted */ private _isAborted; /** Swipe start time */ private _startTime; /** Initial swipe coordinates (internal use) */ private _startCoord; constructor(props?: TS & TM & TModuleOnCallbacksProps<TC, Swipe>, onCallbacks?: TModuleOnCallbacksProps<TC, Swipe>); /** Full coordinate snapshot (pointer space + `movement`). */ get coords(): import("./global").ISwipeCoords; /** Coordinate reference element. */ get container(): HTMLElement | SVGElement; /** Whether release inertia is running. */ get hasInertia(): boolean; /** Whether overflow bounce-back timeline is running. */ get hasBounce(): boolean; /** Whether a swipe gesture is in progress. */ get isSwiping(): boolean; /** Handles property updates */ protected _handleProps(props: Partial<TM>): void; /** Sets event listeners */ private _setEvents; /** Handles `touchstart` events */ private _handleTouchStart; /** Prevents edge swipes if enabled */ private _preventEdgeSwipe; /** Handles pointers start */ private _handlePointersStart; /** Handles pointers end */ private _handlePointersEnd; /** Handles `touchmove` event */ private _handleTouchMove; /** Handles `mousemove` event */ private _handleMouseMove; /** Handles move events */ private _handleMove; /** Checks if swipe can start */ private _canStart; /** Handles move events */ private _move; /** Handles swipe end */ private _handleEnd; /** Reset swipe states */ private _reset; /** Apply inertia-based movement */ private _releaseInertia; /** Apply bounce overflow animation */ releaseBounce(targetDuration?: number): void; /** Cancel inertia */ cancelInertia(): void; /** Cancel bounce */ cancelBounce(): void; /** Calculate swipe bounds */ calculateBounds(): import("./global").ISwipeAxes | undefined; /** Pointer position at swipe start. */ get start(): ISwipeState; /** Previous pointer position. */ get prev(): ISwipeState; /** Current pointer position. */ get current(): ISwipeState; /** Offset from swipe start to current pointer position. */ get diff(): ISwipeState; /** Offset from previous to current pointer position. */ get step(): ISwipeState; /** Absolute path length since swipe start. */ get accum(): ISwipeVec3; /** Total displacement in movement space (use for element transforms). */ get movement(): ISwipeVec3; /** Current scale modifier. */ get scale(): number; /** * Sets programmatic scale in movement space. * Optionally zooms toward an origin point and emits `move`. */ setScale(value: number, origin: MouseEvent | TouchEvent | ISwipeVec2): void; /** * Sets programmatic displacement in movement space. * Reapplies rubber, snap, emits `move`, and cancels overflow bounce. */ setMovement(value: Partial<ISwipeVec3>): void; /** * Destroys the component */ protected _destroy(): void; } //# sourceMappingURL=index.d.ts.map