Skip to content

Commit 36610c7

Browse files
committed
Expose a chain module to easily import for some animations
Particulatly animations that are triggered from an interaction, and the animation needs to be passed thtough a message.
1 parent e1eaaaa commit 36610c7

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/keyframes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use column::Column;
1919
pub use container::Container;
2020
pub use helpers::id;
2121
pub use helpers::lazy;
22-
pub use helpers::{button, column, container, row, space, style_button, style_container};
22+
pub use helpers::{button, column, container, row, space, style_button, style_container, chain};
2323
pub use row::Row;
2424
pub use space::Space;
2525
pub use style_button::StyleButton;

src/keyframes/helpers.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@ pub mod id {
9999
toggler::Id as Toggler,
100100
};
101101
}
102+
103+
/// Direct access to `Chain`s for widget that may return an animation
104+
/// in a message.
105+
pub mod chain {
106+
pub use crate::keyframes::toggler::Chain as Toggler;
107+
}

src/keyframes/toggler.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ impl From<Id> for IcedId {
4545
}
4646

4747
#[derive(Debug, Clone)]
48+
/// An animation, where each keyframe is "chained" together.
4849
pub struct Chain {
4950
id: Id,
5051
links: Vec<Toggler>,
5152
repeat: Repeat,
5253
}
5354

5455
impl Chain {
56+
/// Crate a new [`Toggler`] animation chain.
57+
/// You probably don't want to use use directly, and should
58+
/// use the [`chain`] macro.
5559
pub fn new(id: Id) -> Self {
5660
Chain {
5761
id,
@@ -60,6 +64,9 @@ impl Chain {
6064
}
6165
}
6266

67+
/// Create a chain pre-fulled with children.
68+
/// You probably don't want to use use directly, and should
69+
/// use the [`chain`] macro.
6370
pub fn with_children(id: Id, children: Vec<Toggler>) -> Self {
6471
Chain {
6572
id,
@@ -68,16 +75,24 @@ impl Chain {
6875
}
6976
}
7077

78+
/// Link another keyframe, (very similar to push)
79+
/// You probably don't want to use use directly, and should
80+
/// use the [`chain`] macro.
7181
pub fn link(mut self, toggler: Toggler) -> Self {
7282
self.links.push(toggler);
7383
self
7484
}
7585

86+
/// Sets the animation to loop forever.
7687
pub fn loop_forever(mut self) -> Self {
7788
self.repeat = Repeat::Forever;
7889
self
7990
}
8091

92+
/// Sets the animation to only loop once.
93+
/// This is the default, and only useful to
94+
/// stop an animation that was previously set
95+
/// to loop forever.
8196
pub fn loop_once(mut self) -> Self {
8297
self.repeat = Repeat::Never;
8398
self

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub mod widget;
138138
mod keyframes;
139139

140140
pub use crate::keyframes::{
141-
button, column, container, id, lazy, row, space, style_button, style_container,
141+
button, column, container, id, lazy, row, space, style_button, style_container, chain,
142142
};
143143
pub use crate::timeline::{Chain, Timeline};
144144

0 commit comments

Comments
 (0)