Expand description
§Timing functions for animations:
Easing
: a quadratic bezier curve timing defined by two points and a durationSpring
: a physics-based spring timing, emulating a dumped harmonic oscillator
§Helper functions:
Transition::ease_in(duration: f32) -> Transition
Transition::ease_out(duration: f32) -> Transition
Transition::ease_in_out(duration: f32) -> Transition
Transition::ease_out_quad(duration: f32) -> Transition
Transition::ease_in_quad(duration: f32) -> Transition
Transition::ease_in_out_quad(duration: f32) -> Transition
Transition::spring(duration: f32, bounce: f32) -> Transition
Transition::spring_with_velocity(duration: f32, bounce: f32, velocity: f32) -> Transition
…
§Usage
// use default easing function
layer.set_position((100.0, 100.0), Transition::ease_in(0.3));
// spring helper with perceptual duration and bounce
layer.set_position((100.0, 100.0), Transition::spring(0.3, 0.3));
// spring helper with perceptual duration and initial velocity
layer.set_position((100.0, 100.0), Transition::spring_with_velocity(0.3, 0.3, 0.3));
§Advanced Easing usage
// use custom set a delay and easing function
layer.set_position((100.0, 100.0), Transition {
delay: 0.1,
timing: TimingFunction::ease_in_out_quad(1.0)
});
// use predefined easing functions
layer.set_position((100.0, 100.0), Transition {
delay: 0.0,
timing: TimingFunction::Easing(Easing::ease_in_out_quad(), 0.3)
});
// access the easing parameters directly
layer.set_position((100.0, 100.0), Transition {
delay: 0.0,
timing: TimingFunction::Easing(Easing{x1: 0.0, y1: 0.0, x2: 1.0, y2: 1.0}, 0.3)
});
Structs§
- Animation is a data structure that contains the information needed to animate a property.
- This module contains the animation related data structures
- Transition is a data structure that contains the information needed to create an animation that can start at a later time.
Enums§
- Possible timing functions for an animation.