Input System

SnapEngine normalizes mouse, touch, wheel, drag, and pinch input into one event model. It also handles common edge cases like a mouse leaving the browser while dragging.

SnapEgnine objects can all listen to three types of events: pointer event, drag event, and gesture event.

Pointer Event

Warning

This is not directly related to the official Pointer Event Web API, although it is based on it.

Pointer Events are the simplest type of events. Currently the engine defines these:

  • pointerDown
  • pointerMove
  • pointerUp
  • mouseWheel

These events pass the position of the event in the engine’s world coordinates. For touch devices, the mouseWheel event is never fires, and other pointer events are fired for every touch input (multi touch support). pointerMove will continuously fire for each touch input.

Drag Event

Drag events are designed to handle continuous interaction that persists even when the pointer leaves the browser window or the original element.

The engine defines these drag events:

  • dragStart
  • dragMove
  • dragEnd

These events provide the same world coordinate positions as pointer events but are specifically tailored for drag-and-drop interactions, panning, and other global gestures.

Gesture Event

Gesture events build on lower-level pointer events. They keep track of starts, deltas, endings, and multi-touch state so interaction logic can focus on behavior rather than browser event bookkeeping.

The engine defines these gesture events:

  • pinchStart
  • pinch
  • pinchEnd

These events provide information about multi-touch gestures like pinches.

Global and Local Event

All events listed above can either happen locally (when the pointer is within the bounds of the ElementObject) or globally (triggered for every listener regardless of where the pointer is). BaseObjects can only listen to global events.

For event names, payload shapes, object-level handlers, global handlers, and gesture examples, see Input System reference.