pub trait FloatingActionButtonAnimator: Debug + 'static {
// Required methods
fn get_offset(&self, begin: Offset, end: Offset, progress: f64) -> Offset;
fn get_scale_animation(
&self,
app: &mut App,
parent: AnimationRef<f64>,
) -> AnimationRef<f64>;
fn get_rotation_animation(
&self,
app: &mut App,
parent: AnimationRef<f64>,
) -> AnimationRef<f64>;
// Provided method
fn get_animation_restart(&self, previous_value: f64) -> f64 { ... }
}Expand description
Provider of animations to move the FloatingActionButton between
FloatingActionButtonLocations.
The Scaffold uses Scaffold.floatingActionButtonAnimator to define:
- The
Offsetof theFloatingActionButtonbetween the old and newFloatingActionButtonLocations as part of the transition animation. - An
Animationto scale theFloatingActionButtonduring the transition. - An
Animationto rotate theFloatingActionButtonduring the transition. - Where to start a new animation from if an animation is interrupted.
See also:
FloatingActionButton, which is a circular button typically shown in the bottom right corner of the app.FloatingActionButtonLocation, which theScaffolduses to place theScaffold.floatingActionButtonwithin theScaffold’s layout.
Required Methods§
Sourcefn get_offset(&self, begin: Offset, end: Offset, progress: f64) -> Offset
fn get_offset(&self, begin: Offset, end: Offset, progress: f64) -> Offset
Gets the FloatingActionButton’s position relative to the origin of the
Scaffold based on progress.
begin is the Offset provided by the previous
FloatingActionButtonLocation.
end is the Offset provided by the new
FloatingActionButtonLocation.
progress is the current progress of the transition animation.
When progress is 0.0, the returned Offset should be equal to begin.
when progress is 1.0, the returned Offset should be equal to end.
Sourcefn get_scale_animation(
&self,
app: &mut App,
parent: AnimationRef<f64>,
) -> AnimationRef<f64>
fn get_scale_animation( &self, app: &mut App, parent: AnimationRef<f64>, ) -> AnimationRef<f64>
Animates the scale of the FloatingActionButton.
The animation should both start and end with a value of 1.0.
For example, to create an animation that linearly scales out and then back in,
you could join animations that pass each other with a TrainHoppingAnimation.
Sourcefn get_rotation_animation(
&self,
app: &mut App,
parent: AnimationRef<f64>,
) -> AnimationRef<f64>
fn get_rotation_animation( &self, app: &mut App, parent: AnimationRef<f64>, ) -> AnimationRef<f64>
Animates the rotation of Scaffold.floatingActionButton.
The animation should both start and end with a value of 0.0 or 1.0.
The animation values are a fraction of a full circle, with 0.0 and 1.0 corresponding to 0 and 360 degrees, while 0.5 corresponds to 180 degrees.
For example, to create a rotation animation that rotates the
FloatingActionButton through a full circle, drive a Tween from 0.0 to 1.0 with
parent.
Provided Methods§
Sourcefn get_animation_restart(&self, previous_value: f64) -> f64
fn get_animation_restart(&self, previous_value: f64) -> f64
Gets the progress value to restart a motion animation from when the animation is interrupted.
previous_value is the value of the animation before it was interrupted.
The restart of the animation will affect all three parts of the motion animation: offset animation, scale animation, and rotation animation.
An interruption triggers if the Scaffold is given a new
FloatingActionButtonLocation while it is still animating a transition between two
previous FloatingActionButtonLocations.
A sensible default is usually 0.0, which is the same as restarting the animation from the beginning, regardless of the original state of the animation.
Implementations§
Source§impl dyn FloatingActionButtonAnimator
impl dyn FloatingActionButtonAnimator
Sourcepub fn scaling() -> FloatingActionButtonAnimatorRef
pub fn scaling() -> FloatingActionButtonAnimatorRef
Moves the FloatingActionButton by scaling out and then in at a new
FloatingActionButtonLocation.
This animator shrinks the FloatingActionButton down until it disappears, then
grows it back to full size at its new FloatingActionButtonLocation.
This is the default FloatingActionButton motion animation.
Sourcepub fn no_animation() -> FloatingActionButtonAnimatorRef
pub fn no_animation() -> FloatingActionButtonAnimatorRef
Creates an instance of FloatingActionButtonAnimator where the
FloatingActionButton does not animate on entrance and exit when
FloatingActionButtonLocation is shown or hidden and when transitioning between
FloatingActionButtonLocations.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".