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§
- Drag
Scroll Finish - Result of releasing a pointer tracked by
DragScroller. - Drag
Scroll Update - Result of moving a pointer tracked by
DragScroller. - Drag
Scroller - 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.
- Kinetic
Sampler - Release-velocity estimator for continuous (pixel) scrolling.
- Scroll
Glide - The glide of a scroll view that pans both ways (a document, a canvas, a
wide table): one
ScrollMomentumper 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. - Scroll
Momentum - 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.
- Sparse
Anchor - Stable scroll anchor captured from a model-resolved sparse viewport.
- Sparse
Virtual Viewport - Virtual geometry for collections whose logical item count is much larger than the set of resident keys.
- Virtual
Viewport - Variable-height virtual collection geometry, keyed by model identity.
Enums§
- Reconcile
Error - A key appeared more than once in a reconciliation input.
- Scroll
Alignment - Where an item should land when explicitly scrolled into view.
- Wheel
Step - 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
velocitytravels 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.