Function freya_hooks::use_animation

source ·
pub fn use_animation(init_value: impl FnOnce() -> f64) -> AnimationManager
Expand description

Run animations.

Usage

fn app() -> Element {
    let mut animation = use_animation(|| 0.0);

    let progress = animation.value();

    use_hook(move || {
        animation.start(Animation::new_linear(0.0..=100.0, 50));
    });

    rsx!(
        rect {
            width: "{progress}",
        }
    )
}