pub struct AnimatedValue<T: Interpolate + Clone> { /* private fields */ }Expand description
Animated value that transitions smoothly.
Supports two modes:
- Tween (when
spec.springisNone): interpolates betweenstartandtargetover a fixed duration using an easing curve. - Spring (when
spec.springisSome): numerically integrates a physical spring ODE (x'' = -k·(x - target) - d·x') with emergent duration. When the target changes mid-animation, the current value and velocity carry forward seamlessly.
Implementations§
Source§impl AnimatedValue<f32>
impl AnimatedValue<f32>
Sourcepub fn update_decay(&mut self, friction: f32, stop_threshold: f32) -> bool
pub fn update_decay(&mut self, friction: f32, stop_threshold: f32) -> bool
Tick the decay animation. Returns true if still animating.
Source§impl<T: Interpolate + Clone> AnimatedValue<T>
impl<T: Interpolate + Clone> AnimatedValue<T>
pub fn new(initial: T, spec: AnimationSpec) -> Self
pub fn set_spec(&mut self, spec: AnimationSpec)
Sourcepub fn set_keyframes(&mut self, keyframes: KeyframesSpec<T>)
pub fn set_keyframes(&mut self, keyframes: KeyframesSpec<T>)
Set a keyframes spec for multi-stage animation.
When set, set_target is ignored and the value is driven by the keyframe sequence.
pub fn set_target(&mut self, target: T)
pub fn update(&mut self) -> bool
pub fn get(&self) -> &T
pub fn is_animating(&self) -> bool
pub fn has_keyframes(&self) -> bool
Auto Trait Implementations§
impl<T> Freeze for AnimatedValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for AnimatedValue<T>where
T: RefUnwindSafe,
impl<T> Send for AnimatedValue<T>where
T: Send,
impl<T> Sync for AnimatedValue<T>where
T: Sync,
impl<T> Unpin for AnimatedValue<T>where
T: Unpin,
impl<T> UnsafeUnpin for AnimatedValue<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AnimatedValue<T>where
T: UnwindSafe,
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