Skip to content

@ue-too/board / index / VanillaTouchEventParser

Class: VanillaTouchEventParser ​

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:95

DOM event parser for touch input.

Remarks ​

This parser converts raw DOM TouchEvents into state machine events and coordinates with the orchestrator to process outputs. It serves as the entry point for all touch input in the input interpretation pipeline.

Event Flow:

DOM TouchEvents → Parser → State Machine → Parser → Orchestrator → Camera/Observers

Responsibilities:

  1. Listen for DOM touch events (touchstart/move/end/cancel)
  2. Extract touch point data (identifier, x, y)
  3. Convert to state machine event format
  4. Send events to the state machine
  5. Forward state machine outputs to the orchestrator

Touch Point Extraction:

  • touchstart/touchend: Uses changedTouches (only new/removed touches)
  • touchmove: Uses targetTouches (all touches on the canvas)

Gesture Control: Individual gesture types (pan, zoom, rotate) can be disabled independently, though currently the state machine outputs are filtered by the orchestrator rather than the parser.

The parser prevents default touch behavior to avoid browser scroll/zoom interfering with canvas gestures.

Example ​

typescript
const canvasElement = document.getElementById("canvas");
const stateMachine = createTouchInputStateMachine(context);
const orchestrator = new InputOrchestrator(cameraMux, cameraRig, publisher);
const parser = new VanillaTouchEventParser(stateMachine, orchestrator, canvasElement);

parser.setUp(); // Starts listening for touch events

// Disable zoom gestures temporarily
parser.zoomDisabled = true;

// Cleanup when done
parser.tearDown();

Implements ​

Constructors ​

Constructor ​

new VanillaTouchEventParser(touchInputStateMachine, orchestrator, canvas?): VanillaTouchEventParser

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:107

Parameters ​

touchInputStateMachine ​

TouchInputStateMachine

orchestrator ​

InputOrchestrator

canvas? ​

HTMLCanvasElement | SVGSVGElement

Returns ​

VanillaTouchEventParser

Accessors ​

disabled ​

Get Signature ​

get disabled(): boolean

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:179

Whether all touch input is disabled

Returns ​

boolean

Whether all touch input is disabled

Implementation of ​

TouchEventParser.disabled


orchestrator ​

Get Signature ​

get orchestrator(): InputOrchestrator

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:121

Returns ​

InputOrchestrator


stateMachine ​

Get Signature ​

get stateMachine(): TouchInputStateMachine

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:125

The state machine this parser dispatches into, when the implementation exposes one. Optional so existing external parser implementations remain valid, but note this member is typed to the full TouchInputStateMachine — unlike KMTEventParser.stateMachine's minimal { happens } contract, an external implementation is more likely to need adjustment to satisfy this member's shape. Intended for tooling/introspection — dispatch through the parser, not through this reference.

Returns ​

TouchInputStateMachine

The state machine this parser dispatches into, when the implementation exposes one. Optional so existing external parser implementations remain valid, but note this member is typed to the full TouchInputStateMachine — unlike KMTEventParser.stateMachine's minimal { happens } contract, an external implementation is more likely to need adjustment to satisfy this member's shape. Intended for tooling/introspection — dispatch through the parser, not through this reference.

Implementation of ​

TouchEventParser.stateMachine

Methods ​

attach() ​

attach(canvas): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:267

Attaches to a new canvas element

Parameters ​

canvas ​

HTMLCanvasElement

Returns ​

void

Implementation of ​

TouchEventParser.attach


bindListeners() ​

bindListeners(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:129

Returns ​

void


disable() ​

disable(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:183

Disables the parser; the event listeners are still attached just not processing any events

Returns ​

void

Implementation of ​

TouchEventParser.disable


disableStrategy() ​

disableStrategy(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:140

Returns ​

void


enable() ​

enable(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:187

Enables the parser

Returns ​

void

Implementation of ​

TouchEventParser.enable


enableStrategy() ​

enableStrategy(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:136

Returns ​

void


setUp() ​

setUp(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:144

Initializes event listeners

Returns ​

void

Implementation of ​

TouchEventParser.setUp


tearDown() ​

tearDown(): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:173

Removes event listeners and cleans up

Returns ​

void

Implementation of ​

TouchEventParser.tearDown


touchcancelHandler() ​

touchcancelHandler(e): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:221

Parameters ​

e ​

TouchEvent

Returns ​

void


touchendHandler() ​

touchendHandler(e): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:236

Parameters ​

e ​

TouchEvent

Returns ​

void


touchmoveHandler() ​

touchmoveHandler(e): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:251

Parameters ​

e ​

TouchEvent

Returns ​

void


touchstartHandler() ​

touchstartHandler(e): void

Defined in: packages/board/src/input-interpretation/raw-input-parser/vanilla-touch-event-parser.ts:204

Parameters ​

e ​

TouchEvent

Returns ​

void