Skip to main content

Module zoom

Module zoom 

Source
Expand description

EXP-1586: the ZoomableImage native’s maths (catalog/style.json zoomableImage, whose $comment is the spec). Pure: every painter feeds its pointer, wheel, pinch and key input through these functions, so a zoom, a pan or a double tap lands on the same view everywhere. Mirrors src/zoom.ts; fixtures/zoom.json locks it.

Structs§

ZoomBounds
ZoomFrame
What every function needs to know about the picture and its box.
ZoomLimits
ZoomMenuItem
ZoomPanRoom
ZoomPillSpec
The pill’s geometry (style.json zoomableImage.pill).
ZoomPoint
ZoomSize
ZoomSpec
style.json zoomableImage.
ZoomView
scale = displayed px per image px (1 = 100%); x/y = the picture’s top-left in the viewport.

Enums§

WheelDeltaMode
ZoomInitial
The initial prop (catalog enum zoomInitial); anything else = Auto.

Statics§

ZOOM

Functions§

zoom_at_rest
Whether the view sits at its rest scale.
zoom_bounds
The pill’s disabled ends.
zoom_centre
The viewport’s centre, the anchor of keys and the pill.
zoom_clamp
The view inside its bounds (scale within the limits, no letterbox).
zoom_double_tap
Double click / tap: at rest → zoom in about the point; else → rest.
zoom_double_tap_scale
The scale a double tap at rest jumps to.
zoom_drag
A drag from start by (dx, dy) while held: past an edge the overshoot rubber-bands. The release is zoom_clamp of the last view.
zoom_fit_scale
The whole picture inside the viewport, never upscaled: the minimum.
zoom_is_tall
A picture taller than 1 / tallAspect times its width.
zoom_key
A key while the picture has focus; None = not a zoom key.
zoom_ladder
The ladder steps walk: the presets plus the rest scale, inside the limits, ascending.
zoom_limits
The scale range: [fit, max(fit, maxScale)].
zoom_menu
The % button’s Menu: Fit, then the menu presets inside the limits.
zoom_momentum
Mouse-drag momentum t ms after a release at velocity (px/ms), exponential decay, stopping at the edges.
zoom_momentum_active
Whether momentum t ms after a release is still moving (above 0.01 px/ms).
zoom_pan_room
The axes the picture can pan on: an axis without room hands a swipe to the host (paging).
zoom_percent
The pill’s label: round(scale × 100) + % (JS Math.round: halves up).
zoom_pinch
A pinch from start by the raw factor about anchor while held: past the min/max the scale rubber-bands (d = the limit). The release is zoom_clamp of the last view.
zoom_request
THE JSON entry (the FFI’s zoom_json, the fixture replays ×4): {op, frame: {natural, viewport, initial?, maxScale?}, from?: view | "rest", …} with the op named like the fixtures/zoom.json group it answers: rest, clamp {view}, zoomTo {scale, anchor}, wheel {deltaY, mode, anchor}, scroll {deltaX, deltaY}, ladder, steps {scale, direction}, step {direction} (a view), doubleTap {point}, keys {key}, rubberBand {overshoot, extent}, drag {dx, dy}, pinch {factor, anchor}, momentum {vx, vy, t}, momentumActive {vx, vy, t}, panRoom, resize {fromViewport} (from: "rest" = the rest view at the OLD viewport), percent {scale}, menu {fitLabel?}, bounds.
zoom_resize
A new viewport: at rest = the new rest view; zoomed = the same scale about the viewport centre, clamped.
zoom_rest_scale
The scale the picture opens at (and a double tap / 0 / the fit button returns to), inside the limits.
zoom_rest_view
The opening view: the rest scale, centred; a taller-than-the-viewport picture starts at its top.
zoom_rubber_band
The overshoot past an edge, damped: (1 − 1 / (o·c/d + 1))·d.
zoom_scroll
A plain wheel / two-finger scroll: pans by the deltas, clamped.
zoom_step
/ − (keys and the pill) about the viewport centre.
zoom_step_scale
The next ladder scale strictly above (1) or below (-1) the current one, or the current one at the end.
zoom_to
Zoom to scale (clamped) keeping the image point under anchor fixed.
zoom_wheel
One ⌘/ctrl-wheel event about the cursor.
zoom_wheel_factor
⌘/ctrl + wheel (or a trackpad pinch delivered as a wheel): the scale factor of one wheel event.