Skip to main content

integrate_scroll

Function integrate_scroll 

Source
pub fn integrate_scroll(
    tick: Res<'_, Tick>,
    anim: Res<'_, AnimationsActive>,
    q: Query<'_, '_, (&mut ScrollOffset, &mut Scroll)>,
)
Expand description

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.

Stops integrating when |velocity| falls below VELOCITY_SLEEP_PX_PER_S to avoid eternal tiny redraws.