pub struct ClampingSimulation { /* private fields */ }Expand description
Android OverScroller’s friction fling, bounded by a scroll range.
The content decelerates along Android’s spline and stops dead at min or
max — no overshoot, no bounce. This is the Clamp half of the pair, and
the physics every Teksilo scrollable gets unless its theme or its owner asks
for the other one.
use std::time::Duration;
use teksilo_core::kinetic::{ClampingSimulation, ScrollSimulation};
use teksilo_tokens::ScrollPhysicsTokens;
let tokens = ScrollPhysicsTokens::DEFAULT;
let sim = ClampingSimulation::new(0.0, 4000.0, -1.0e6, 1.0e6, &tokens);
// Android's getSplineFlingDistance(4000) — see the tests for the arithmetic.
assert!((sim.position(sim.duration()) - 2156.95).abs() < 1.0);
assert!(sim.is_done(sim.duration()));Implementations§
Source§impl ClampingSimulation
impl ClampingSimulation
Sourcepub fn new(
position: f32,
velocity: f32,
min: f32,
max: f32,
tokens: &ScrollPhysicsTokens,
) -> Self
pub fn new( position: f32, velocity: f32, min: f32, max: f32, tokens: &ScrollPhysicsTokens, ) -> Self
A fling released at position with velocity, confined to
[min, max].
Pass a very wide range for an unbounded coast — that is what
FlingDriver does, since the widget receiving the
re-dispatched deltas owns the real bounds.
Trait Implementations§
Source§impl Clone for ClampingSimulation
impl Clone for ClampingSimulation
Source§fn clone(&self) -> ClampingSimulation
fn clone(&self) -> ClampingSimulation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClampingSimulation
impl Debug for ClampingSimulation
Auto Trait Implementations§
impl Freeze for ClampingSimulation
impl RefUnwindSafe for ClampingSimulation
impl Send for ClampingSimulation
impl Sync for ClampingSimulation
impl Unpin for ClampingSimulation
impl UnsafeUnpin for ClampingSimulation
impl UnwindSafe for ClampingSimulation
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