pub fn use_animation_transition<Animated, T>(
value: impl IntoReadable<T>,
run: impl FnMut(T, T) -> Animated + 'static,
) -> 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.))
}