pub struct VelocityTracker { /* private fields */ }Expand description
The shared animation layer — physics, curves, driver — see
frus_core::animation. Re-exported here so applications can reach it through
frus_widgets without depending on frus-core directly.
A rolling history of pointer positions that can be asked for a velocity.
Adding a position is cheap; asking for the estimate is not free (the regression strategy solves a small system), so ask once, at the release.
Implementations§
Source§impl VelocityTracker
impl VelocityTracker
Sourcepub fn new(strategy: VelocityStrategy) -> VelocityTracker
pub fn new(strategy: VelocityStrategy) -> VelocityTracker
A tracker using strategy.
Sourcepub fn platform_default() -> VelocityTracker
pub fn platform_default() -> VelocityTracker
The strategy the running platform reads flings with.
Resolved at compile time from the target, like the scroll physics it feeds: a build is for one platform.
Sourcepub fn strategy(&self) -> VelocityStrategy
pub fn strategy(&self) -> VelocityStrategy
The strategy in force.
Sourcepub fn add_position(&mut self, time: f32, point: Point)
pub fn add_position(&mut self, time: f32, point: Point)
Records where the pointer was, and when (in seconds).
Sourcepub fn estimate(&self, now: f32) -> Option<VelocityEstimate>
pub fn estimate(&self, now: f32) -> Option<VelocityEstimate>
The estimate as of now (seconds, same clock as the samples), or None
when not a single position has been recorded.
Sourcepub fn velocity(&self, now: f32) -> Velocity
pub fn velocity(&self, now: f32) -> Velocity
The estimated velocity as of now, or Velocity::ZERO if there is
nothing to go on.
Trait Implementations§
Source§impl Clone for VelocityTracker
impl Clone for VelocityTracker
Source§fn clone(&self) -> VelocityTracker
fn clone(&self) -> VelocityTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more