Function freya::prelude::use_animation

source ·
pub fn use_animation(
    cx: &ScopeState,
    init_value: impl FnOnce() -> f64
) -> AnimationManager<'_>
Expand description

Run animations.

Usage

fn app(cx: Scope) -> Element {
    let animation = use_animation(cx, || 0.0);

    let progress = animation.value();

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

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