use blinc_animation::{keyframe::MultiKeyframeAnimation, AnimationPreset, SpringConfig};
#[derive(Clone, Debug)]
pub struct PageTransition {
pub enter: MultiKeyframeAnimation,
pub exit: MultiKeyframeAnimation,
pub spring: Option<SpringConfig>,
}
impl PageTransition {
pub fn new(enter: MultiKeyframeAnimation, exit: MultiKeyframeAnimation) -> Self {
Self {
enter,
exit,
spring: None,
}
}
pub fn slide() -> Self {
Self::new(
AnimationPreset::slide_in_right(300, 0.0),
AnimationPreset::slide_out_right(300, 0.0),
)
}
pub fn fade() -> Self {
Self::new(
AnimationPreset::fade_in(200),
AnimationPreset::fade_out(200),
)
}
pub fn modal() -> Self {
Self::new(
AnimationPreset::slide_in_bottom(300, 0.0),
AnimationPreset::slide_out_bottom(300, 0.0),
)
}
pub fn scale() -> Self {
Self::new(
AnimationPreset::scale_in(250),
AnimationPreset::scale_out(200),
)
}
pub fn none() -> Self {
Self::new(AnimationPreset::fade_in(0), AnimationPreset::fade_out(0))
}
pub fn with_spring(mut self, spring: SpringConfig) -> Self {
self.spring = Some(spring);
self
}
}
impl Default for PageTransition {
fn default() -> Self {
Self::slide()
}
}