From ae35992048e7717a6e4308841859bfb6c0a7d51c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 28 Jan 2025 03:24:48 +0100 Subject: Add `repeat`, `repeat_forever`, and `auto_reverse` to `Animation` --- core/src/animation.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'core/src') diff --git a/core/src/animation.rs b/core/src/animation.rs index 5ff31544..258fd084 100644 --- a/core/src/animation.rs +++ b/core/src/animation.rs @@ -67,6 +67,26 @@ where self } + /// Makes the [`Animation`] repeat a given amount of times. + /// + /// Providing 1 repetition plays the animation twice in total. + pub fn repeat(mut self, repetitions: u32) -> Self { + self.raw = self.raw.repeat(repetitions); + self + } + + /// Makes the [`Animation`] repeat forever. + pub fn repeat_forever(mut self) -> Self { + self.raw = self.raw.repeat_forever(); + self + } + + /// Makes the [`Animation`] automatically reverse when repeating. + pub fn auto_reverse(mut self) -> Self { + self.raw = self.raw.auto_reverse(); + self + } + /// Transitions the [`Animation`] from its current state to the given new state. pub fn go(mut self, new_state: T) -> Self { self.go_mut(new_state); -- cgit