Expand description
Scroll primitive.
- Tag a container with
Scrollto declare its axes. accumulate_wheelreadsMouseWheelmessages and updatesScrollOffseton the directly-hovered scrollable entity.- The default extract fns consume
ScrollOffsetvialumen_core::render_world::parent_scroll_offsets. - Clipping (
overflow: hidden) is handled inlumen-layout-taffy.
Structs§
- Scroll
Plugin - Plugin: registers
accumulate_wheelandintegrate_scroll. The scroll-aware extract path is supplied by lumen-core’s default extracts - they queryScrollOffsetdirectly and translate descendants accordingly.
Constants§
- MAX_
INTEGRATION_ DT_ MS - Upper bound on per-tick integration step. After a suspend / hot
reload / debugger pause,
Tick.dtcan 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 theirrequestAnimationFramerate 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
ScrollOffsetof 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::ScrollIntoViewAccessKit actions. - clamp_
scroll_ offsets - Clamp every
ScrollOffsetto[0, content - viewport]per axis, with macOS-style rubber-band overshoot driven bycrate::physics::RUBBER_BAND_STIFFNESS. Runs after layout so childTransforms reflect the current content extent. - integrate_
scroll - Per-tick: apply
Scroll::velocity(px/s) toScrollOffsetand decay velocity per the OS-specificcrate::physics::INERTIA_DECAYconstant. Reads wall-clockdtfrom the sharedTickresource so every scroller integrates against the same frame clock, clamped toMAX_INTEGRATION_DT_MSso 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 wayapply_a11y_scroll_into_viewdoes for AT-drivenScrollIntoView.