Skip to main content

Module virtual_viewport

Module virtual_viewport 

Expand description

Shared one-dimensional virtualization geometry for lists, trees, and tables.

VirtualViewport keeps stable item keys, lazily measured heights, a Fenwick prefix-sum index, and the scroll position in one place. Collection widgets use it for four operations that must agree exactly: visible-range calculation, row placement, hit testing, and scrollbar metrics.

Reconciliation is anchor-preserving. Inserting, removing, or resizing rows above the first visible item does not move the content under the user’s eyes. Measured heights follow stable keys across moves; unseen rows retain the configured estimate until measured.

Structs§

DragScrollFinish
Result of releasing a pointer tracked by DragScroller.
DragScrollUpdate
Result of moving a pointer tracked by DragScroller.
DragScroller
Thresholded, single-axis pointer panning shared by virtual collections. A press remains a click until it moves four logical pixels; once active, offset and release velocity are derived from the same pointer samples.
KineticSampler
Release-velocity estimator for continuous (pixel) scrolling.
ScrollGlide
The glide of a scroll view that pans both ways (a document, a canvas, a wide table): one ScrollMomentum per axis, so it decays as every list glides (glide_step) and steps in whole device pixels, which a host that copies what a scroll keeps on screen copies.
ScrollMomentum
Deterministic single-axis momentum used by virtualized collection widgets. Wheel input moves immediately; line-wheel impulses additionally feed this decay curve so detented wheels can traverse long collections without requiring one event per row.
SparseAnchor
Stable scroll anchor captured from a model-resolved sparse viewport.
SparseVirtualViewport
Virtual geometry for collections whose logical item count is much larger than the set of resident keys.
VirtualViewport
Variable-height virtual collection geometry, keyed by model identity.

Enums§

ReconcileError
A key appeared more than once in a reconciliation input.
ScrollAlignment
Where an item should land when explicitly scrolled into view.
WheelStep
What a vertical collection should do with one wheel event, decided by ScrollMomentum::wheel.

Constants§

FLING_DECAY_PER_SECOND
How quickly a fling slows, per second: velocity decays as v(t) = v₀·e^(−k·t). One rate for every scroll surface, so lists (ScrollMomentum) and documents (Scrollable) glide alike.
GLIDE_REST_SPEED
Below this speed (logical px/s) a glide has come to rest.

Functions§

glide_rest_distance
How far a glide at velocity travels before it rests: the whole integral of the decay, v₀/k, which its steps (glide_step) cover exactly whatever the frame rate.
glide_step
Advance a fling by seconds: the distance it covers and the velocity it keeps. The distance is the exact integral of the decay, so one 40 ms step lands where four 10 ms steps do — a fling travels the same at 25, 60 and 90 fps, and after a stalled frame. No clamp: a stall is covered, not dropped.