Skip to content

Commit 5b96d61

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 598597e commit 5b96d61

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
@@ -61,13 +61,17 @@ impl From<Id> for IcedId {
6161
}
6262

6363
#[derive(Debug, Clone)]
64+
/// An animation, where each keyframe is "chained" together.
6465
pub struct Chain {
6566
id: Id,
6667
links: Vec<Toggler>,
6768
repeat: Repeat,
6869
}
6970

7071
impl Chain {
72+
/// Crate a new [`Toggler`] animation chain.
73+
/// You probably don't want to use use directly, and should
74+
/// use the [`chain`] macro.
7175
pub fn new(id: Id) -> Self {
7276
Chain {
7377
id,
@@ -76,6 +80,9 @@ impl Chain {
7680
}
7781
}
7882

83+
/// Create a chain pre-fulled with children.
84+
/// You probably don't want to use use directly, and should
85+
/// use the [`chain`] macro.
7986
pub fn with_children(id: Id, children: Vec<Toggler>) -> Self {
8087
Chain {
8188
id,
@@ -84,16 +91,24 @@ impl Chain {
8491
}
8592
}
8693

94+
/// Link another keyframe, (very similar to push)
95+
/// You probably don't want to use use directly, and should
96+
/// use the [`chain`] macro.
8797
pub fn link(mut self, toggler: Toggler) -> Self {
8898
self.links.push(toggler);
8999
self
90100
}
91101

102+
/// Sets the animation to loop forever.
92103
pub fn loop_forever(mut self) -> Self {
93104
self.repeat = Repeat::Forever;
94105
self
95106
}
96107

108+
/// Sets the animation to only loop once.
109+
/// This is the default, and only useful to
110+
/// stop an animation that was previously set
111+
/// to loop forever.
97112
pub fn loop_once(mut self) -> Self {
98113
self.repeat = Repeat::Never;
99114
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)