Skip to main content

Module interact

Module interact 

Source
Expand description

Map interaction following the MapLibre GL / Mapbox GL JS default handlers, adapted to terminal mouse reports (cells, or pixels with SGR-pixels mode):

  • wheel / two-finger scroll: zoom around the cursor (MapLibre trackpad rate, 1/100 per px)
  • drag: pan, with inertia on release (160 ms window, linearity 0.3, max 1400 px/s, deceleration 2500 px/s², easing cubic-bezier(0, 0, 0.3, 1))
  • double-click: zoom in one level around the point; shift+double-click: zoom out
  • shift+drag: box zoom
  • keyboard: arrows pan 100 px, +/- zoom to the next whole level, eased over 300 ms with the default easing cubic-bezier(0.25, 0.1, 0.25, 1)
  • a single click is reported to the app (for feature inspection) via Controller::take_click

Terminal extras: hjkl pan, sideways swipes pan, and a row-scroll mode for the smooth-scroll region protocol (see crate::smooth).

Structs§

Bezier
CSS-style cubic bezier easing (the WebKit UnitBezier solver MapLibre uses).
Click
A single click (not a drag or double-click) the app may want to act on, such as picking the feature under it.
Controller
Mouse and keyboard handling for a map, MapLibre style. Feed it events, call Controller::tick each frame, and draw with cam. See the module docs.

Constants§

DEFAULT_EASING
MapLibre’s default easing for camera moves.
INERTIA_EASING
MapLibre’s easing for drag inertia.