diff --git a/crates/gpui/src/elements/animation.rs b/crates/gpui/src/elements/animation.rs index bcdfa3562c747999dde96498e046ce7bd4629ac2..11dd19e260c20e49b87e05137771be73a3f816ea 100644 --- a/crates/gpui/src/elements/animation.rs +++ b/crates/gpui/src/elements/animation.rs @@ -1,4 +1,7 @@ -use std::time::{Duration, Instant}; +use std::{ + rc::Rc, + time::{Duration, Instant}, +}; use crate::{ AnyElement, App, Element, ElementId, GlobalElementId, InspectorElementId, IntoElement, Window, @@ -8,6 +11,7 @@ pub use easing::*; use smallvec::SmallVec; /// An animation that can be applied to an element. +#[derive(Clone)] pub struct Animation { /// The amount of time for which this animation should run pub duration: Duration, @@ -15,7 +19,7 @@ pub struct Animation { pub oneshot: bool, /// A function that takes a delta between 0 and 1 and returns a new delta /// between 0 and 1 based on the given easing function. - pub easing: Box f32>, + pub easing: Rc f32>, } impl Animation { @@ -25,7 +29,7 @@ impl Animation { Self { duration, oneshot: true, - easing: Box::new(linear), + easing: Rc::new(linear), } } @@ -39,7 +43,7 @@ impl Animation { /// The easing function will take a time delta between 0 and 1 and return a new delta /// between 0 and 1 pub fn with_easing(mut self, easing: impl Fn(f32) -> f32 + 'static) -> Self { - self.easing = Box::new(easing); + self.easing = Rc::new(easing); self } }