DynamicAnimationKt

public final class DynamicAnimationKt


Summary

Public methods

static final @NonNull FlingAnimation
flingAnimationOf(
    @NonNull Function1<@NonNull FloatUnit> setter,
    @NonNull Function0<@NonNull Float> getter
)

Creates FlingAnimation for a property that can be accessed via the provided setter and getter.

static final @NonNull SpringAnimation
springAnimationOf(
    @NonNull Function1<@NonNull FloatUnit> setter,
    @NonNull Function0<@NonNull Float> getter,
    float finalPosition
)

Creates SpringAnimation for a property that can be accessed via the provided setter and getter.

static final @NonNull SpringAnimation

Updates or applies spring force properties like SpringForce.mDampingRatio, SpringForce.mFinalPosition and stiffness on SpringAnimation.

Public methods

flingAnimationOf

@NonNull
public static final FlingAnimation flingAnimationOf(
    @NonNull Function1<@NonNull FloatUnit> 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 FloatUnit> setter

The function that mutates the property being animated

@NonNull Function0<@NonNull Float> getter

The function that returns the value of the property

springAnimationOf

@NonNull
public static final SpringAnimation springAnimationOf(
    @NonNull Function1<@NonNull FloatUnit> 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 FloatUnit> 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

SpringForce.mFinalPosition Final position of spring.

DynamicAnimationKt.withSpringForceProperties

@NonNull
public static final SpringAnimation DynamicAnimationKt.withSpringForceProperties(
    @NonNull SpringAnimation receiver,
    @NonNull Function1<@NonNull SpringForceUnit> 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 SpringForceUnit> func

lambda with receiver on SpringForce