UNPKG

@niuee/board

Version:

<h1 align="center"> board </h1> <p align="center"> board supercharges your html canvas element giving it the capabilities to pan, zoom, rotate, and much more. </p> <p align="center"> <a href="https://www.npmjs.com/package/@niuee/board">

75 lines (74 loc) 2.75 kB
import { EventReactions, EventGuards, Guard, TemplateState, TemplateStateMachine } from "../being/interfaces"; import { TouchContext } from "./touch-input-context"; export type TouchStates = "IDLE" | "PENDING" | "IN_PROGRESS"; /** * @description The touch points. * * @category Input State Machine */ export type TouchPoints = { ident: number; x: number; y: number; }; /** * @description The touch event payload. * * @category Input State Machine */ export type TouchEventPayload = { points: TouchPoints[]; }; /** * @description The touch event mapping. * * @category Input State Machine */ export type TouchEventMapping = { touchstart: TouchEventPayload; touchmove: TouchEventPayload; touchend: TouchEventPayload; }; /** * @description The idle state of the touch input state machine. * * @category Input State Machine */ export declare class IdleState extends TemplateState<TouchEventMapping, TouchContext, TouchStates> { private _eventReactions; protected _guards: Guard<TouchContext, "touchPointsCount">; protected _eventGuards: Partial<EventGuards<TouchEventMapping, TouchStates, TouchContext, typeof this._guards>>; get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates>; touchstart(context: TouchContext, payload: TouchEventPayload): void; touchend(context: TouchContext, payload: TouchEventPayload): void; } /** * @description The pending state of the touch input state machine. * * @category Input State Machine */ export declare class PendingState extends TemplateState<TouchEventMapping, TouchContext, TouchStates> { private _eventReactions; get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates>; touchstart(context: TouchContext, payload: TouchEventPayload): void; touchend(context: TouchContext, payload: TouchEventPayload): void; touchmove(context: TouchContext, payload: TouchEventPayload): void; } /** * @description The in progress state of the touch input state machine. * * @category Input State Machine */ export declare class InProgressState extends TemplateState<TouchEventMapping, TouchContext, TouchStates> { private _eventReactions; get eventReactions(): EventReactions<TouchEventMapping, TouchContext, TouchStates>; touchmove(context: TouchContext, payload: TouchEventPayload): void; touchend(context: TouchContext, payload: TouchEventPayload): void; } /** * @description The touch input state machine. * * @category Input State Machine */ export type TouchInputStateMachine = TemplateStateMachine<TouchEventMapping, TouchContext, TouchStates>; export declare function createTouchInputStateMachine(context: TouchContext): TouchInputStateMachine;