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.

117 lines 4.07 kB
import { Module, TModuleOnCallbacksProps } from '../../base'; import { TRequiredProps } from '../../internal/requiredProps'; import { IPointersCallbacksMap, IPointersItem, IPointersMove, IPointersMutableProps, IPointersStaticProps } from './types'; export * from './types'; type TC = IPointersCallbacksMap; type TS = IPointersStaticProps; type TM = IPointersMutableProps; /** * Manages pointer events, including tracking multiple pointers, * and emitting callbacks for pointer interactions. * * For proper functionality, ensure the container has an appropriate * [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) property. * * [Documentation](https://vevetjs.com/docs/Pointers) * * @group Components */ export declare class Pointers extends Module<TC, TS, TM> { /** * Returns the default static properties. */ _getStatic(): TRequiredProps<TS>; /** * Returns the default mutable properties. */ _getMutable(): TRequiredProps<TM>; /** * Stores active event listeners for runtime interactions. */ private _listeners; /** Indicates whether the `start` event has been triggered. */ private _isStarted; /** Map of active pointers. */ private _pointersMap; /** Save minPointers value */ private _saveMinPointers; /** Move data. */ private _moveData; /** Whether a microtask `move` emit is scheduled. */ private _moveScheduled; /** Angle data */ private _angle; constructor(props?: TS & TM & TModuleOnCallbacksProps<TC, Pointers>, onCallbacks?: TModuleOnCallbacksProps<TC, Pointers>); /** Indicates whether the `start` event has been triggered. */ get isStarted(): boolean; /** Returns the map of active pointers. */ get pointersMap(): Map<number, IPointersItem>; /** Returns the container element handling events. */ get container(): HTMLElement | SVGElement; /** Move data */ get move(): IPointersMove | null; /** Get buttons */ private _getButtons; /** Get max pointers */ private _getMinPointers; /** Get max pointers */ private _getMaxPointers; /** Normalize pointer event type */ private _getPointerType; /** * Attaches base event listeners to the container. */ private _setBaseEvents; /** * Attaches runtime event listeners for active pointer interactions. */ private _setRuntimeEvents; /** * Handles pointer down events (`pointerdown`). * Adds a new pointer if conditions are met and triggers the `pointerdown` callback. */ private _handlePointerDown; /** * Handles pointer movement (`pointermove`). * Updates pointer positions and triggers the `pointermove` callback. */ private _handlePointerMove; /** * Handles pointer release (`pointerup`). * Removes the pointer and triggers the `pointerup` callback. * If no active pointers remain, fires the `end` callback. */ private _handlePointerUp; /** * Handles event cancellations (`pointercancel`, `blur`). * Triggers the `end` callback and cleans up all pointers. */ private _handleCancel; /** * Prevents text selection during pointer interactions. */ private _resetSelection; /** * Returns pointer coordinates relative to the container. */ private _decodeCoords; /** Update move data */ private _updateMove; /** Returns the angle between the first two pointers (deg). */ private _getAngle; /** Returns the average center position of points. */ private _getAverageCenter; /** Returns the average distance between points */ private _getAverageDistance; /** Schedules a deduplicated `move` callback for the current microtask. */ private _scheduleMove; /** * Cleans up event listeners, pointers, and injected styles. */ private _cleanup; /** * Destroys the component and removes all event listeners. */ protected _destroy(): void; } //# sourceMappingURL=index.d.ts.map