pub struct FlingAnimation { /* private fields */ }Expand description
Drives a fling (decay) animation on a scroll target.
Each frame, it calculates the scroll DELTA based on the decay curve and applies it to the scroll target via the provided callback.
Implementations§
Source§impl FlingAnimation
impl FlingAnimation
Sourcepub fn new(runtime: RuntimeHandle) -> Self
pub fn new(runtime: RuntimeHandle) -> Self
Creates a new fling animation driver.
Sourcepub fn start_fling<F, G>(
&self,
initial_value: f32,
velocity: f32,
density: f32,
on_scroll: F,
on_end: G,
)
pub fn start_fling<F, G>( &self, initial_value: f32, velocity: f32, density: f32, on_scroll: F, on_end: G, )
Starts a fling animation with the given velocity.
§Arguments
initial_value- Current scroll position (used as reference)velocity- Initial velocity in px/sec (from VelocityTracker)density- Screen density for physics calculationson_scroll- Callback invoked each frame with scroll DELTA (not absolute position)on_end- Callback invoked when animation completes
pub fn cancel(&self)
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true if a fling animation is currently running.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlingAnimation
impl !RefUnwindSafe for FlingAnimation
impl !Send for FlingAnimation
impl !Sync for FlingAnimation
impl Unpin for FlingAnimation
impl !UnwindSafe for FlingAnimation
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