pub fn use_animation_transition<Animated: AnimatedValue, T: Clone + PartialEq + 'static>(
value: impl IntoReadable<T>,
run: impl 'static + FnMut(T, T) -> Animated,
) -> UseAnimation<Animated>Expand description
Create a transition animation that animates from the previous value to the current value.
This hook tracks the previous and current values of a reactive value and creates an animation that transitions between them when the value changes.
ยงExample
fn app() -> impl IntoElement {
let color = use_state(|| Color::RED);
let animation =
use_animation_transition(color, |from: Color, to| AnimColor::new(from, to).time(500));
rect()
.background(&*animation.read())
.width(Size::px(100.))
.height(Size::px(100.))
}