DynamicAnimationKt
public final class DynamicAnimationKt
Summary
Public methods |
|
|---|---|
static final @NonNull FlingAnimation |
flingAnimationOf(Creates |
static final @NonNull SpringAnimation |
springAnimationOf(Creates |
static final @NonNull SpringAnimation |
withSpringForceProperties(Updates or applies spring force properties like |
Public methods
flingAnimationOf
public static final @NonNull FlingAnimation flingAnimationOf(
@NonNull Function1<@NonNull Float, Unit> setter,
@NonNull Function0<@NonNull Float> getter
)
Creates FlingAnimation for a property that can be accessed via the provided setter and getter. For example, the following sample code creates a FlingAnimation for the alpha property of a View object named view: flingAnimationOf(view::setAlpha, view::getAlpha)
| Parameters | |
|---|---|
@NonNull Function1<@NonNull Float, Unit> setter |
The function that mutates the property being animated |
@NonNull Function0<@NonNull Float> getter |
The function that returns the value of the property |
| Returns | |
|---|---|
@NonNull FlingAnimation |
springAnimationOf
public static final @NonNull SpringAnimation springAnimationOf(
@NonNull Function1<@NonNull Float, Unit> setter,
@NonNull Function0<@NonNull Float> getter,
float finalPosition
)
Creates SpringAnimation for a property that can be accessed via the provided setter and getter. If finalPosition is not Float.NaN then create SpringAnimation with SpringForce.mFinalPosition.
| Parameters | |
|---|---|
@NonNull Function1<@NonNull Float, Unit> setter |
The function that mutates the property being animated |
@NonNull Function0<@NonNull Float> getter |
The function that returns the value of the property |
float finalPosition |
|
| Returns | |
|---|---|
@NonNull SpringAnimation |
withSpringForceProperties
public static final @NonNull SpringAnimation withSpringForceProperties(
@NonNull SpringAnimation receiver,
@NonNull Function1<@NonNull SpringForce, Unit> func
)
Updates or applies spring force properties like SpringForce.mDampingRatio, SpringForce.mFinalPosition and stiffness on SpringAnimation.
If SpringAnimation.mSpring is null in case SpringAnimation is created without final position it will be created and attached to SpringAnimation
| Parameters | |
|---|---|
@NonNull Function1<@NonNull SpringForce, Unit> func |
lambda with receiver on |
| Returns | |
|---|---|
@NonNull SpringAnimation |