pub struct BouncingScrollSimulation { /* private fields */ }Expand description
The rest of the animation layer: tweens chained and curved, the scroll simulations and their constants. 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,
) -> BouncingScrollSimulation
pub fn new( position: f32, velocity: f32, leading: f32, trailing: f32, spring: SpringDescription, tolerance: Tolerance, ) -> BouncingScrollSimulation
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,
) -> BouncingScrollSimulation
pub fn with_constant_deceleration( position: f32, velocity: f32, leading: f32, trailing: f32, spring: SpringDescription, tolerance: Tolerance, constant_deceleration: f32, ) -> BouncingScrollSimulation
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.
Trait Implementations§
Source§impl Clone for BouncingScrollSimulation
impl Clone for BouncingScrollSimulation
Source§fn clone(&self) -> BouncingScrollSimulation
fn clone(&self) -> BouncingScrollSimulation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more