UNPKG

@ue-too/board

Version:
65 lines (64 loc) 2.59 kB
import { EventReactions, EventGuards, Guard, TemplateState, TemplateStateMachine } from "@ue-too/being"; import { TouchContext, TouchPoints } from "./touch-input-context"; export type TouchStates = "IDLE" | "PENDING" | "IN_PROGRESS"; /** * @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;