pub struct MomentumState {
pub velocity_x: f32,
pub velocity_y: f32,
}Expand description
Per-frame simulation state for momentum scrolling.
Fields§
§velocity_x: f32§velocity_y: f32Implementations§
Source§impl MomentumState
impl MomentumState
pub fn new() -> Self
Sourcepub fn push(&mut self, dx: f32, dy: f32)
pub fn push(&mut self, dx: f32, dy: f32)
Apply a drag delta to velocity (called on pointer move).
Sourcepub fn tick(&mut self, physics: ScrollPhysics) -> (f32, f32)
pub fn tick(&mut self, physics: ScrollPhysics) -> (f32, f32)
Advance momentum simulation by one frame. Returns (dx, dy) to apply to offset.
Sourcepub fn is_settled(&self) -> bool
pub fn is_settled(&self) -> bool
Returns true when both velocity components are below the stop threshold.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MomentumState
impl RefUnwindSafe for MomentumState
impl Send for MomentumState
impl Sync for MomentumState
impl Unpin for MomentumState
impl UnsafeUnpin for MomentumState
impl UnwindSafe for MomentumState
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
Mutably borrows from an owned value. Read more