androidx.ui.foundation.animation

Classes

AndroidFlingCalculator

Configuration for Android-feel flinging motion at the given density.

AndroidFlingDecayAnimation

A native Android fling curve decay.

AnimatedValueHolder

Value holder that allows to animate value that it holds.

FlingConfig

Class to specify fling behavior.

Top-level functions summary

FlingConfig
AnchorsFlingConfig(anchors: List<Float>, animationBuilder: AnimationBuilder<Float> = PhysicsBuilder(), onAnimationEnd: OnAnimationEnd? = null, decayAnimation: DecayAnimation = ExponentialDecay())

Create fling config with anchors will make sure that after drag has ended, the value will be animated to one of the points from the predefined list.

FlingConfig
FlingConfig(onAnimationEnd: OnAnimationEnd? = null, adjustTarget: (Float) -> TargetAnimation? = { null })

Specify fling behavior configured for the current composition.

AnimatedValueHolder
animatedDragValue(initial: Float, minBound: Float, maxBound: Float)

Effect to construct and memorize value holder

Extension functions summary

For AnimatedFloat
Unit
AnimatedFloat.fling(config: FlingConfig, startVelocity: Float)

Starts a fling animation with the specified starting velocity and fling configuration.

Top-level functions

AnchorsFlingConfig

fun AnchorsFlingConfig(
    anchors: List<Float>,
    animationBuilder: AnimationBuilder<Float> = PhysicsBuilder(),
    onAnimationEnd: OnAnimationEnd? = null,
    decayAnimation: DecayAnimation = ExponentialDecay()
): FlingConfig

Create fling config with anchors will make sure that after drag has ended, the value will be animated to one of the points from the predefined list.

It takes velocity into account, though value will be animated to the closest point in provided list considering velocity.

Parameters
anchors: List<Float> set of anchors to animate to
onAnimationEnd: OnAnimationEnd? = null callback to be invoked when animation value reaches desired anchor or fling being interrupted by gesture input. Consult AnimationEndReason param to know what happened.
animationBuilder: AnimationBuilder<Float> = PhysicsBuilder() animation which will be used for animations
decayAnimation: DecayAnimation = ExponentialDecay() decay animation to be used to calculate closest point in the anchors set considering velocity.

FlingConfig

@Composable fun FlingConfig(
    onAnimationEnd: OnAnimationEnd? = null,
    adjustTarget: (Float) -> TargetAnimation? = { null }
): FlingConfig

Specify fling behavior configured for the current composition. See FlingConfig.

Parameters
onAnimationEnd: OnAnimationEnd? = null callback to be invoked when fling finishes by decay or being interrupted by gesture input. Consider second boolean param "cancelled" to know what happened.
adjustTarget: (Float) -> TargetAnimation? = { null } callback to be called at the start of fling so the final value for fling can be adjusted

animatedDragValue

@Composable fun animatedDragValue(
    initial: Float,
    minBound: Float,
    maxBound: Float
): AnimatedValueHolder

Effect to construct and memorize value holder

This effects sets initial value inside this holder to initial, and can rewrite min and max bound without reconstructing the whole holder if they change.

Parameters
initial: Float initial value to put inside the value holder
minBound: Float minimal bound for the value inside the holder
maxBound: Float maximal bound for the value inside the holder

Extension functions

fling

fun AnimatedFloat.fling(
    config: FlingConfig,
    startVelocity: Float
): Unit

Starts a fling animation with the specified starting velocity and fling configuration.

Parameters
config: FlingConfig configuration that specifies fling behaviour
startVelocity: Float Starting velocity of the fling animation