Skip to main content

ScrollPhysics

Struct ScrollPhysics 

Source
pub struct ScrollPhysics {
    pub friction: f32,
    pub stiffness: f32,
    pub damping: f32,
    pub rubber_band_limit: f32,
}
Expand description

Configurable physics constants for ScrollState.

Not #[non_exhaustive]: unlike this crate’s enums, this type’s whole point is direct struct- literal construction, which #[non_exhaustive] would forbid for external crates (including via functional update syntax). Construct a custom value off ScrollPhysics::DEFAULT with functional update syntax instead of naming every field, so a field added here later needs at most a call-site addition rather than a rewrite:

use retroglyph_ui::state::ScrollPhysics;

let physics = ScrollPhysics { friction: 6.0, ..ScrollPhysics::DEFAULT };

Fields§

§friction: f32

Exponential friction decay constant. Higher means faster deceleration.

§stiffness: f32

Stiffness of the overscroll spring.

§damping: f32

Damping of the overscroll spring.

§rubber_band_limit: f32

Maximum rows/cells the viewport can be rubber-banded past the edge.

Implementations§

Source§

impl ScrollPhysics

Source

pub const DEFAULT: Self

The default scroll physics parameters as a constant.

The spring pair (stiffness/damping) is close to but deliberately under critical damping: critical would be damping = 2 * sqrt(stiffness) = 2 * sqrt(180) ~= 26.8, and 24.0 sits just below that, so the rubber band settles with one small visible bounce rather than a dead stop. friction and the stiffness magnitude were tuned by feel for a row-per-item viewport at ~60fps, not derived; treat them as adjustable.

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

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

impl Default for ScrollPhysics

Source§

fn default() -> Self

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

impl PartialEq for ScrollPhysics

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<C> WithAlpha for C
where C: Copy,

§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see [AlphaFirst]).
§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see [AlphaLast]).