diff options
author | 2025-02-09 08:36:34 +0100 | |
---|---|---|
committer | 2025-02-09 08:36:34 +0100 | |
commit | 12653114bd1cadb10b9fe185b6f2b1e4300bdcf7 (patch) | |
tree | 8fa2254a1eb36685fd93241db638d2ad65856bcb /core/src/animation.rs | |
parent | 65bf503963bb58186ba7a60f6b6010e8a3b41ae7 (diff) | |
parent | e0d60d58391535d96f0864da4a4dde50d5669543 (diff) | |
download | iced-12653114bd1cadb10b9fe185b6f2b1e4300bdcf7.tar.gz iced-12653114bd1cadb10b9fe185b6f2b1e4300bdcf7.tar.bz2 iced-12653114bd1cadb10b9fe185b6f2b1e4300bdcf7.zip |
Merge pull request #2796 from tarkah/feat/gallery-enhancements
Add blurhash to gallery
Diffstat (limited to 'core/src/animation.rs')
-rw-r--r-- | core/src/animation.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/animation.rs b/core/src/animation.rs index 258fd084..14cbb5c3 100644 --- a/core/src/animation.rs +++ b/core/src/animation.rs @@ -13,6 +13,7 @@ where T: Clone + Copy + PartialEq + Float, { raw: lilt::Animated<T, Instant>, + duration: Duration, // TODO: Expose duration getter in `lilt` } impl<T> Animation<T> @@ -23,6 +24,7 @@ where pub fn new(state: T) -> Self { Self { raw: lilt::Animated::new(state), + duration: Duration::from_millis(100), } } @@ -58,6 +60,7 @@ where /// Sets the duration of the [`Animation`] to the given value. pub fn duration(mut self, duration: Duration) -> Self { self.raw = self.raw.duration(duration.as_secs_f32() * 1_000.0); + self.duration = duration; self } @@ -133,4 +136,13 @@ impl Animation<bool> { { self.raw.animate_bool(start, end, at) } + + /// Returns the remaining [`Duration`] of the [`Animation`]. + pub fn remaining(&self, at: Instant) -> Duration { + Duration::from_secs_f32(self.interpolate( + self.duration.as_secs_f32(), + 0.0, + at, + )) + } } |