Skip to main content

Module scroll

Module scroll 

Source
Expand description

Scroll primitive.

Structs§

ScrollPlugin
Plugin: registers accumulate_wheel and integrate_scroll. The scroll-aware extract path is supplied by lumen-core’s default extracts - they query ScrollOffset directly and translate descendants accordingly.

Constants§

MAX_INTEGRATION_DT_MS
Upper bound on per-tick integration step. After a suspend / hot reload / debugger pause, Tick.dt can balloon into seconds; without a cap the inertial fling launches the offset off the page in a single tick. 100 ms matches the wall-clock budget most browsers use for their requestAnimationFrame rate limiters after backgrounding.
VELOCITY_SLEEP_PX_PER_S
Velocity below which the integrator snaps to zero, in px/s. At 60 Hz a velocity of 3 px/s produces ~0.05 px of motion per frame - imperceptible, but heavy enough to avoid eternal sub-pixel ticks.

Functions§

accumulate_wheel
Accumulate wheel deltas into the ScrollOffset of the innermost scrollable ancestor of whatever entity the pointer is hovering that can still scroll in the event’s direction (spec section 16.5).
apply_a11y_scroll_into_view
W5.3 consumer for inbound Action::ScrollIntoView AccessKit actions.
clamp_scroll_offsets
Clamp every ScrollOffset to [0, content - viewport] per axis, with macOS-style rubber-band overshoot driven by crate::physics::RUBBER_BAND_STIFFNESS. Runs after layout so child Transforms reflect the current content extent.
integrate_scroll
Per-tick: apply Scroll::velocity (px/s) to ScrollOffset and decay velocity per the OS-specific crate::physics::INERTIA_DECAY constant. Reads wall-clock dt from the shared Tick resource so every scroller integrates against the same frame clock, clamped to MAX_INTEGRATION_DT_MS so a post-suspend frame doesn’t fling the offset off the page.
scroll_on_keys
Keyboard scrolling for the focused entity, or - when the focused entity isn’t itself scrollable - its nearest Scroll-bearing ancestor. Walks the [ChildOf] chain the same way apply_a11y_scroll_into_view does for AT-driven ScrollIntoView.