pub fn clamp_scroll_offsets(
children_q: Query<'_, '_, (&ChildOf, &Transform)>,
scrolls: Query<'_, '_, (Entity, &Transform, &mut Scroll, &mut ScrollOffset)>,
)Expand description
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.
Content extent is computed as the bounding box of the scroll
container’s direct children - virtualized <for> blocks set their
own size to rows x row_h, so the bbox correctly reflects the
scrollable region.
Rubber-band model: when stiffness > 0, an offset past the bound is
pulled back via bound + overflow / (1 + stiffness * |overflow|)
(a Hooke spring approximation). When stiffness is 0 (Windows /
Linux defaults), the offset hard-clamps and velocity is zeroed on
the clamped axis so inertial flings don’t keep pumping into the
wall - matching the pre-rubber-band behaviour.