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::ScrollPhysics;
let physics = ScrollPhysics { friction: 6.0, ..ScrollPhysics::DEFAULT };Fields§
§friction: f32Exponential friction decay constant. Higher means faster deceleration.
stiffness: f32Stiffness of the overscroll spring.
damping: f32Damping of the overscroll spring.
rubber_band_limit: f32Maximum rows/cells the viewport can be rubber-banded past the edge.
Implementations§
Source§impl ScrollPhysics
impl ScrollPhysics
Sourcepub const DEFAULT: Self
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
impl Clone for ScrollPhysics
Source§fn clone(&self) -> ScrollPhysics
fn clone(&self) -> ScrollPhysics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScrollPhysics
impl Debug for ScrollPhysics
Source§impl Default for ScrollPhysics
impl Default for ScrollPhysics
Source§impl PartialEq for ScrollPhysics
impl PartialEq for ScrollPhysics
Source§fn eq(&self, other: &ScrollPhysics) -> bool
fn eq(&self, other: &ScrollPhysics) -> bool
self and other values to be equal, and is used by ==.impl Copy for ScrollPhysics
impl StructuralPartialEq for ScrollPhysics
Auto Trait Implementations§
impl Freeze for ScrollPhysics
impl RefUnwindSafe for ScrollPhysics
impl Send for ScrollPhysics
impl Sync for ScrollPhysics
impl Unpin for ScrollPhysics
impl UnsafeUnpin for ScrollPhysics
impl UnwindSafe for ScrollPhysics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).