Skip to main content

ScrollPhysics

Enum ScrollPhysics 

Source
pub enum ScrollPhysics {
    Bouncing(ScrollDecelerationRate),
    Clamping,
}
Expand description

Re-export: size classes and orientation, so the application can drive its own responsive behaviour. The behaviour of a scrollable at its edges and after a fling.

Variants§

§

Bouncing(ScrollDecelerationRate)

Overscroll is allowed, resisted, and springs back — at the given rate.

§

Clamping

Overscroll is refused; a fling stops at the edge.

Implementations§

Source§

impl ScrollPhysics

Source

pub const BOUNCING: ScrollPhysics

Bouncing physics at a finger’s deceleration — the common case, and what ScrollPhysics::BOUNCING meant before there were two.

Source

pub fn deceleration_rate(self) -> Option<ScrollDecelerationRate>

The deceleration profile in force, or None for a family that has none.

Source§

impl ScrollPhysics

Source

pub const fn platform_default() -> ScrollPhysics

What the running platform expects. Bouncing where the system scroll views bounce, clamping everywhere else.

This is resolved at compile time from the target, not at runtime: a build is for one platform, and a constant keeps the choice out of the frame loop.

Source

pub fn spring(self) -> SpringDescription

The spring that returns overscrolled content to its edge.

Source

pub fn tolerance(self) -> Tolerance

The thresholds under which the motion counts as finished.

Source

pub fn min_fling_velocity(self) -> f32

The release speed under which a drag does not fling at all.

Bouncing physics decelerates far more gently, so it asks for a more deliberate gesture before it commits to a fling.

Source

pub fn max_fling_velocity(self) -> f32

The cap on a release speed.

A pointing device can be flicked far harder than a finger can — a wheel notch or a two-finger flick on a trackpad reports speeds no fingertip reaches — so the fast profile lifts the ceiling eightfold rather than clipping what the hardware actually said.

Source

pub fn drag_start_distance_threshold(self) -> f32

The distance a finger must cover before the content starts to move, in px.

Bouncing physics asks for a little more, to swallow the small unintended motion of a finger lifting off.

Source

pub fn carried_momentum(self, existing_velocity: f32) -> f32

The speed carried over when a fling is thrown on top of one already running — the repeated-swipe speed-up.

Only the bouncing family builds momentum this way; clamping starts each fling from the gesture alone.

Source

pub fn apply_user_offset(self, metrics: ScrollMetrics, delta: f32) -> f32

How much of a finger’s delta actually reaches the offset.

Inside the content it is all of it. Past an edge, the bouncing family applies a friction that falls off quadratically with how far out we already are: the further you pull, the less each pixel of finger buys — the rubber band. Easing back towards the content is measured at the position the gesture is heading to, so releasing tension is easier than adding it.

Source

pub fn apply_boundary_conditions( self, metrics: ScrollMetrics, value: f32, ) -> f32

The part of a proposed move that must be refused, so that the caller can apply value - refused.

Clamping physics refuses everything that would leave the content; bouncing physics refuses nothing, and lets the spring deal with it.

Source

pub fn allows_overscroll(self) -> bool

May the content be dragged past its edges at all?

Source

pub fn ballistic( self, metrics: ScrollMetrics, velocity: f32, ) -> Option<Ballistic>

The motion that follows the finger lifting off at velocity (px/s, positive meaning the offset grows). None when nothing should move.

Source

pub fn page_ballistic( self, metrics: ScrollMetrics, velocity: f32, extent: f32, ) -> Option<Ballistic>

The motion that follows the finger lifting off a paged area, where the content may not come to rest between two pages. extent is the distance from one page to the next.

This replaces the fling rather than correcting it afterwards: a paged view never coasts. Whatever the release speed, the content springs to one page — the next one on a flick, the nearer one otherwise. A fling that crossed three pages and then had to be caught and pulled back would be a different, worse gesture.

Past an edge and still heading out, there is no page to go to, so the ordinary physics takes over — which is what brings the overscroll home, with the platform’s own bounce or clamp.

Trait Implementations§

Source§

impl Clone for ScrollPhysics

Source§

fn clone(&self) -> ScrollPhysics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ScrollPhysics

Source§

impl Debug for ScrollPhysics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ScrollPhysics

Source§

fn default() -> ScrollPhysics

Returns the “default value” for a type. Read more
Source§

impl Eq for ScrollPhysics

Source§

impl Hash for ScrollPhysics

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ScrollPhysics

Source§

fn eq(&self, other: &ScrollPhysics) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScrollPhysics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more