@protorians/widgets
Version:
Create your web user interfaces with widgets
54 lines (53 loc) • 2.82 kB
TypeScript
import type { IAttributes, IGestureDetail, IGestureEventMap, IGestureOptions, IWidgetNode, IGesture, IGestureCallable, IGestureTrackingCallable } from "./types/index.js";
import { GestureType } from "./enums.js";
import { ISignalStack } from "@protorians/core";
export declare class Gesture<E extends HTMLElement, A extends IAttributes> implements IGesture<E, A> {
readonly widget: IWidgetNode<E, A>;
protected startX: number;
protected startY: number;
protected startTime: number;
protected startDist: number;
protected longPressTimer: number | undefined;
protected lastTapTime: number;
protected _options: Required<IGestureOptions>;
readonly signal: ISignalStack<IGestureEventMap>;
get options(): IGestureOptions;
constructor(widget: IWidgetNode<E, A>, options?: IGestureOptions);
protected onStartMouse: (e: MouseEvent) => void;
protected onMoveMouse: (e: MouseEvent) => void;
protected onEndMouse: (e: MouseEvent) => void;
protected onStartTouch: (e: TouchEvent) => void;
protected onMoveTouch: (e: TouchEvent) => void;
protected onEndTouch: (e: TouchEvent) => void;
protected resolveGesture(x: number, y: number): this;
protected initLongPress(): void;
protected clearLongPress(): void;
protected checkDoubleTap(): void;
protected getDistance(touches: TouchList): number;
protected setStart(x: number, y: number): void;
option<K extends keyof IGestureOptions>(key: K, value: IGestureOptions[K]): this;
listen<K extends GestureType>(type: K, callable: IGestureCallable): this;
any(callable: IGestureCallable): this;
tracking(callable: IGestureTrackingCallable): this;
start(callable: IGestureTrackingCallable): this;
end(callable: IGestureTrackingCallable): this;
dispatch<K extends GestureType>(type: K, detail: IGestureDetail): this;
destroy(): void;
slideLeft(callable: IGestureCallable): this;
slideRight(callable: IGestureCallable): this;
slideTop(callable: IGestureCallable): this;
slideBottom(callable: IGestureCallable): this;
slideTopLeft(callable: IGestureCallable): this;
slideTopRight(callable: IGestureCallable): this;
slideBottomLeft(callable: IGestureCallable): this;
slideBottomRight(callable: IGestureCallable): this;
slideX(callable: IGestureCallable): this;
slideY(callable: IGestureCallable): this;
swipe(callable: IGestureCallable): this;
swing(callable: IGestureCallable): this;
zoomIn(callable: IGestureCallable): this;
zoomOut(callable: IGestureCallable): this;
doubleTap(callable: IGestureCallable): this;
longPress(callable: IGestureCallable): this;
}
export declare function createGesture<E extends HTMLElement, A extends IAttributes>(widget: IWidgetNode<E, A>, options?: IGestureOptions): Gesture<E, A>;