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() -> Bouncing
pub fn new() -> Bouncing
A standalone bouncing physics at DecelerationRate::Normal.
Sourcepub fn with_rate(rate: DecelerationRate) -> Bouncing
pub fn with_rate(rate: DecelerationRate) -> Bouncing
A standalone bouncing physics at rate.
Sourcepub fn chain(self, parent: impl ScrollPhysics + 'static) -> Bouncing
pub fn chain(self, parent: impl ScrollPhysics + 'static) -> Bouncing
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).Source§fn min_fling_velocity(&self) -> f64
fn min_fling_velocity(&self) -> f64
Source§fn spring(&self) -> SpringDescription
fn spring(&self) -> SpringDescription
Source§fn max_fling_velocity(&self) -> f64
fn max_fling_velocity(&self) -> f64
Source§fn tolerance_for(&self, metrics: &ScrollMetrics) -> Tolerance
fn tolerance_for(&self, metrics: &ScrollMetrics) -> Tolerance
Auto Trait Implementations§
impl !RefUnwindSafe for Bouncing
impl !Send for Bouncing
impl !Sync for Bouncing
impl !UnwindSafe for Bouncing
impl Freeze for Bouncing
impl Unpin for Bouncing
impl UnsafeUnpin for Bouncing
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.