Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Animation

Animation allows you to configure a specific animation with the following properties duration, easing, and whether it should repeat or not. This animation can then be applied to element with with_animation

Creating an animation

The new function takes a Duration this and returns the Animation.

use std::time::Duration;

use gpui::Animation;

fn main() {
    Animation::new(Duration::from_secs(1));
}

Repeating animation

The repeat function will make the animation repeat indefinitely.

use std::time::Duration;

use gpui::Animation;

fn main() {
    Animation::new(Duration::from_secs(1)).repeat();
}

Easing animation

The with_easing function takes a impl Fn(f32) -> f32 this closure takes a delta and allows you to modify the delta during the animation which allows easing.

GPUI supplies various easing functions that you may want to use such as linear, quadratic, ease_in_out, and ease_out_quint.

use std::time::Duration;

use gpui::{Animation, ease_in_out};

fn main() {
    Animation::new(Duration::from_secs(1)).with_easing(ease_in_out);
}