DynamicAnimationKt

Added in 1.0.0-alpha04

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

public 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. 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

public 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. 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.

withSpringForceProperties

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

lambda with receiver on SpringForce