Skip to main content

keyframes

Function keyframes 

Source
pub fn keyframes(value: &Signal<f64>, frames: Keyframes)
Expand description

Takes value through frames (SwiftUI’s keyframe animator): a pulse, a shake, a count-up, a bounce; each step reached with its own timing. Reduce Motion skips to the last value (a repeating one stays at its start).

use ferrokit::*;

// A nudge: right, left, and back to rest; a canvas draws it offset.
let shake = Signal::new(0.0);
let card = canvas(move |p| p.fill_rounded_rect(shake.get(), 0.0, p.width(), p.height(), 8.0, Color::Red));
keyframes(&shake, Keyframes::new(0.0).to(8.0, 0.08).to(-6.0, 0.1).with(0.0, Animation::snappy()));