pub struct RubberBand { /* private fields */ }Expand description
The iOS-style rubber-band scroll feel: a drag may pull the position past an
edge, resisted by [OVERSCROLL_RESISTANCE], and nothing about a boundary is
rejected. See the module docs for what the trait does not carry
for this physics.
Implementations§
Source§impl RubberBand
impl RubberBand
Sourcepub fn new() -> RubberBand
pub fn new() -> RubberBand
A standalone rubber-band physics (no chained parent).
Sourcepub fn chain(self, parent: impl ScrollPhysics + 'static) -> RubberBand
pub fn chain(self, parent: impl ScrollPhysics + 'static) -> RubberBand
Chain parent behind this physics, the module-wide composition
convention (ScrollPhysics’ Chaining): every method this type does
not override walks up to parent.
Trait Implementations§
Source§impl Debug for RubberBand
impl Debug for RubberBand
Source§impl Default for RubberBand
impl Default for RubberBand
Source§fn default() -> RubberBand
fn default() -> RubberBand
Source§impl ScrollPhysics for RubberBand
impl ScrollPhysics for RubberBand
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
The past-edge portion of the drag is scaled by
[OVERSCROLL_RESISTANCE]; the portion that keeps the position inside
[min, max] passes through untouched. A delta straddling an edge is
split between the two rather than resisted whole.
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: a rubber-band surface holds an out-of-range position for as long as the finger asks it to, and the release-settle (not a boundary rule) is what brings it back.
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>>
No generic ballistic simulation — both scroll surfaces keep their
own hand-rolled fling (fling_decay/fling_displacement) and
release-settle for this physics, which is exactly what makes installing
it a no-op on the shipped feel. A None here is the documented contract
for “the widget’s legacy path owns post-release motion”, not a gap to
fill in later by this type: a physics that does want the generic
driver returns a Simulation, and the widget then drives that instead.
Source§fn carried_momentum(&self, _existing_velocity: f64) -> f64
fn carried_momentum(&self, _existing_velocity: f64) -> f64
A re-fling during live motion starts cold, matching both widgets’
shipped behavior (a new Down kills the fling outright).
Source§fn should_accept_user_offset(&self, _metrics: &ScrollMetrics) -> bool
fn should_accept_user_offset(&self, _metrics: &ScrollMetrics) -> bool
Always true, deliberately overriding the trait’s
has-scrollable-content default: a ScrollView/ListView whose content
fits its viewport still rubber-bands under the finger today, and
matching the shipped feel wins over the more principled default.
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 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
Source§fn spring(&self) -> SpringDescription
fn spring(&self) -> SpringDescription
Auto Trait Implementations§
impl !RefUnwindSafe for RubberBand
impl !Send for RubberBand
impl !Sync for RubberBand
impl !UnwindSafe for RubberBand
impl Freeze for RubberBand
impl Unpin for RubberBand
impl UnsafeUnpin for RubberBand
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.