Skip to main content

DurationWithEasing

Trait DurationWithEasing 

Source
pub trait DurationWithEasing {
    // Required methods
    fn with_easing(self, easing: impl Fn(f32) -> f32 + 'static) -> Motion;
    fn with_spring(self, config: SpringConfig) -> Motion;
}
Expand description

The former name of MotionDurationExt. Adds motion constructors to Duration, including duration.with_easing(...).

Import this trait to call its methods. Each method forwards to the matching Motion method on a single forward pass.

§Examples

use std::time::Duration;

use gpui::{MotionDurationExt, ease_out_quint};

let motion = Duration::from_millis(300).with_easing(ease_out_quint());
assert_eq!(motion.forward_pass().duration(), Duration::from_millis(300));

Required Methods§

Source

fn with_easing(self, easing: impl Fn(f32) -> f32 + 'static) -> Motion

Creates a one-pass motion of this duration with the given easing function.

Source

fn with_spring(self, config: SpringConfig) -> Motion

Creates a motion of this duration whose easing is a spring sampled over that duration. See Motion::with_spring.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MotionDurationExt for Duration

Source§

fn with_easing(self, easing: impl Fn(f32) -> f32 + 'static) -> Motion

Source§

fn with_spring(self, config: SpringConfig) -> Motion

Implementors§