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§
- Zoom
Bounds - Zoom
Frame - What every function needs to know about the picture and its box.
- Zoom
Limits - Zoom
Menu Item - Zoom
PanRoom - Zoom
Pill Spec - The pill’s geometry (style.json
zoomableImage.pill). - Zoom
Point - Zoom
Size - Zoom
Spec - style.json
zoomableImage. - Zoom
View - scale = displayed px per image px (1 = 100%); x/y = the picture’s top-left in the viewport.
Enums§
- Wheel
Delta Mode - Zoom
Initial - The
initialprop (catalog enumzoomInitial); anything else =Auto.
Statics§
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
startby (dx, dy) while held: past an edge the overshoot rubber-bands. The release iszoom_clampof 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
tms after a release at velocity (px/ms), exponential decay, stopping at the edges. - zoom_
momentum_ active - Whether momentum
tms 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) +
%(JSMath.round: halves up). - zoom_
pinch - A pinch from
startby the raw factor aboutanchorwhile held: past the min/max the scale rubber-bands (d = the limit). The release iszoom_clampof 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 underanchorfixed. - 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.