pub struct BouncingScrollSimulation { /* private fields */ }Expand description
A fling that rolls on friction while inside the content and springs back once past its edge — the behaviour of platforms that bounce.
It is two simulations end to end: FrictionSimulation up to the instant the
momentum would carry the offset past an edge, then a SpringSimulation from
that edge, seeded with the velocity the friction had left at the hand-over.
Starting already out of range skips straight to the spring.
The hand-over instant is computed once, at construction, from
FrictionSimulation::time_at_x — so sampling stays a pure function of time.
Implementations§
Source§impl BouncingScrollSimulation
impl BouncingScrollSimulation
Sourcepub fn new(
position: f32,
velocity: f32,
leading: f32,
trailing: f32,
spring: SpringDescription,
tolerance: Tolerance,
) -> Self
pub fn new( position: f32, velocity: f32, leading: f32, trailing: f32, spring: SpringDescription, tolerance: Tolerance, ) -> Self
A fling from position at velocity, springing back to leading or
trailing — the offsets the content is allowed to rest at.
Sourcepub fn with_constant_deceleration(
position: f32,
velocity: f32,
leading: f32,
trailing: f32,
spring: SpringDescription,
tolerance: Tolerance,
constant_deceleration: f32,
) -> Self
pub fn with_constant_deceleration( position: f32, velocity: f32, leading: f32, trailing: f32, spring: SpringDescription, tolerance: Tolerance, constant_deceleration: f32, ) -> Self
The same fling with a constant deceleration on top of the drag — the second deceleration profile, for input that is not a finger.
Nought gives exactly Self::new. See
FrictionSimulation::with_constant_deceleration for what the term does and
why the closed forms stop working.