Skip to main content

animate

Function animate 

Source
pub fn animate(value: &Signal<f64>, to: f64, animation: Animation)
Expand description

Animates value from where it is to to with animation, setting it every frame (about 120 times a second): views and drawings that read it follow. A spring passes to and comes back; a new animation of the same signal takes over from where it is. With Reduce Motion on, it’s set to to at once.

use ferrokit::*;

let level = Signal::new(0.0);
let fill = button("Fill", move || animate(&level, 1.0, Animation::bouncy()));
let gauge = canvas(move |p| p.fill_rect(0.0, 0.0, p.width() * level.get(), p.height(), Color::Green));