pub struct Bouncing { /* private fields */ }Expand description
iOS’s scroll feel — Flutter’s BouncingScrollPhysics: a drag may pull the
position past an edge against a friction factor that tightens with depth,
nothing is ever boundary-rejected, and a release runs an exponential
friction curve that hands over to a rubber-band spring at whichever edge it
reaches.
See the module docs for the drag convention the surfaces hand this curve its depth through, and for the deviations from the Dart source.
Implementations§
Source§impl Bouncing
impl Bouncing
Sourcepub const MIN_FLING_VELOCITY: f64
pub const MIN_FLING_VELOCITY: f64
Flutter’s BouncingScrollPhysics.minFlingVelocity: twice
super::MIN_FLING_VELOCITY, because this physics’ ballistic curve
decelerates more slowly than the clamping one, so a fling has to be a
more deliberate flick to be worth starting.
Sourcepub fn new() -> Self
pub fn new() -> Self
A standalone bouncing physics at DecelerationRate::Normal.
Sourcepub fn with_rate(rate: DecelerationRate) -> Self
pub fn with_rate(rate: DecelerationRate) -> Self
A standalone bouncing physics at rate.
Sourcepub fn chain(self, parent: impl ScrollPhysics + 'static) -> Self
pub fn chain(self, parent: impl ScrollPhysics + 'static) -> Self
Chain parent behind this physics, the module-wide composition
convention (ScrollPhysics’ Chaining).
Sourcepub fn friction_factor(&self, overscroll_fraction: f64) -> f64
pub fn friction_factor(&self, overscroll_fraction: f64) -> f64
The fraction of a past-edge pull that reaches the position at an
overscroll of overscroll_fraction viewports — Flutter’s
frictionFactor: 0.52·(1 − f)² at DecelerationRate::Normal,
0.26·(1 − f)² at DecelerationRate::Fast.
Trait Implementations§
Source§impl ScrollPhysics for Bouncing
impl ScrollPhysics for Bouncing
Source§fn apply_physics_to_user_offset(
&self,
metrics: &ScrollMetrics,
offset: f64,
) -> f64
fn apply_physics_to_user_offset( &self, metrics: &ScrollMetrics, offset: f64, ) -> f64
Travel inside the range passes through untouched, travel that deepens
an overscroll is scaled by Self::friction_factor at the depth
already held, and travel easing back toward the range passes through
untouched too. That asymmetry is the signature of the feel: pulling
further out gets progressively heavier, letting it back never fights
the finger.
Source§fn apply_boundary_conditions(
&self,
_metrics: &ScrollMetrics,
_value: f64,
) -> f64
fn apply_boundary_conditions( &self, _metrics: &ScrollMetrics, _value: f64, ) -> f64
Nothing is ever rejected — holding an out-of-range position is the whole point of a bouncing surface, and the edge spring (not a boundary rule) is what returns it.
Source§fn create_ballistic_simulation(
&self,
metrics: &ScrollMetrics,
velocity: f64,
) -> Option<Box<dyn Simulation>>
fn create_ballistic_simulation( &self, metrics: &ScrollMetrics, velocity: f64, ) -> Option<Box<dyn Simulation>>
An overscrolled surface always gets its spring back, in range a fling
needs Self::MIN_FLING_VELOCITY, and anything else is no motion at
all.
Source§fn should_accept_user_offset(&self, _metrics: &ScrollMetrics) -> bool
fn should_accept_user_offset(&self, _metrics: &ScrollMetrics) -> bool
Always true: an iOS surface whose content fits its viewport still
scrolls — it just bounces straight back.
Source§fn carried_momentum(&self, existing_velocity: f64) -> f64
fn carried_momentum(&self, existing_velocity: f64) -> f64
Flutter’s fitted power curve, capped at MOMENTUM_CAP (40000 px/s) and
signed like the motion it carries over.
Source§fn parent(&self) -> Option<&dyn ScrollPhysics>
fn parent(&self) -> Option<&dyn ScrollPhysics>
chain(...).
None for a physics built standalone (the chain’s root).