Skip to content

Commit ae35992

Browse files
committed
Add repeat, repeat_forever, and auto_reverse to Animation
1 parent 23d42d2 commit ae35992

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

core/src/animation.rs

+20
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@ where
6767
self
6868
}
6969

70+
/// Makes the [`Animation`] repeat a given amount of times.
71+
///
72+
/// Providing 1 repetition plays the animation twice in total.
73+
pub fn repeat(mut self, repetitions: u32) -> Self {
74+
self.raw = self.raw.repeat(repetitions);
75+
self
76+
}
77+
78+
/// Makes the [`Animation`] repeat forever.
79+
pub fn repeat_forever(mut self) -> Self {
80+
self.raw = self.raw.repeat_forever();
81+
self
82+
}
83+
84+
/// Makes the [`Animation`] automatically reverse when repeating.
85+
pub fn auto_reverse(mut self) -> Self {
86+
self.raw = self.raw.auto_reverse();
87+
self
88+
}
89+
7090
/// Transitions the [`Animation`] from its current state to the given new state.
7191
pub fn go(mut self, new_state: T) -> Self {
7292
self.go_mut(new_state);

0 commit comments

Comments
 (0)