Expand description
Types for creating animations.
Animations in Cushy are performed by transitioning a Dynamic’s contained
value over time. This starts with Dynamic::transition_to(), which
returns a DynamicTransition.
DynamicTransition implements AnimationTarget, a trait that describes
types that can be updated using linear interpolation.
AnimationTarget is also implemented for tuples of AnimationTarget
implementors, allowing multiple transitions to be an AnimationTarget.
Next, the AnimationTarget is turned into an animation by invoking
AnimationTarget::over() with the Duration the transition should
occur over. The animation can further be customized using
Animation::with_easing() to utilize any Easing implementor.
use std::time::Duration;
use cushy::animation::easings::EaseInOutElastic;
use cushy::animation::{AnimationTarget, Spawn};
use cushy::reactive::value::{Dynamic, Source};
let value = Dynamic::new(0);
let mut reader = value.create_reader();
value
.transition_to(100)
.over(Duration::from_millis(100))
.with_easing(EaseInOutElastic)
.launch();
drop(value);
while reader.block_until_updated() {
println!("{}", reader.get());
}
assert_eq!(reader.get(), 100);Modules§
- Built-in
Easingimplementations.
Structs§
- A handle to a spawned animation. When dropped, the associated animation will be stopped.
- A wrapper that implements
LinearInterpolatesuch that the value switches after 50%. - An animation combinator that runs animation
A, then animationB. - An animation that repeats another animation.
- A pending transition for a
Dynamicto a new value. - An easing function for customizing animations.
- A wrapper that implements
LinearInterpolatesuch that the target value is immediately returned as long as percent is > 0. - An animation wrapper that invokes a callback upon the animation completing.
- A
Chainthat is currently animating. - A
DynamicTransitionthat has begun its transition. - An
f32that is clamped between 0.0 and 1.0 and cannot be NaN or Infinity.
Traits§
- A type that can animate.
- The target of an
Animateimplementor. - A target for a timed
Animation. - A type that can convert into
Box<dyn Animate>. - Performs easing for value interpolation.
- A type that can be converted into an animation.
- Performs a linear interpolation between two values.
- Calculates the ratio of one value against a minimum and maximum.
- An animation that can be spawned.
Derive Macros§
- Derives
LinerarInterpolatefor structs and fieldless enums.