pub struct ScrollClock { /* private fields */ }Expand description
A Clock that derives delta-time from scroll position changes.
Instead of measuring wall time, ScrollClock converts position changes
(in any unit — pixels, percentage, etc.) into normalised animation progress.
The delta() value represents the fraction of the scroll range that
was traversed since the last call, which can be fed directly into
Update::update().
Implementations§
Source§impl ScrollClock
impl ScrollClock
Sourcepub fn new(start: f32, end: f32) -> Self
pub fn new(start: f32, end: f32) -> Self
Create a new ScrollClock mapping position from start to end.
The animation progresses from 0.0 to 1.0 as position moves from
start to end. Scrolling backwards produces negative delta.
Sourcepub fn set_position(&mut self, position: f32)
pub fn set_position(&mut self, position: f32)
Set the current scroll position.
The difference from the previous position is accumulated and returned
by the next Clock::delta call.
Trait Implementations§
Source§impl Clock for ScrollClock
impl Clock for ScrollClock
Source§impl Clone for ScrollClock
impl Clone for ScrollClock
Source§fn clone(&self) -> ScrollClock
fn clone(&self) -> ScrollClock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ScrollClock
impl RefUnwindSafe for ScrollClock
impl Send for ScrollClock
impl Sync for ScrollClock
impl Unpin for ScrollClock
impl UnsafeUnpin for ScrollClock
impl UnwindSafe for ScrollClock
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