Google berkomitmen untuk mendorong terwujudnya keadilan rasial bagi komunitas Kulit Hitam. Lihat caranya.

androidx.ui.foundation.animation

Classes

AndroidFlingDecaySpec

A native Android fling curve decay.

FlingConfig

Class to specify fling behavior.

Top-level functions summary

FlingConfig
FlingConfig(anchors: List<Float>, animationSpec: AnimationSpec<Float> = SpringSpec(), decayAnimation: FloatDecayAnimationSpec = 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
defaultFlingConfig(adjustTarget: (Float) -> TargetAnimation? = { null })

Default FlingConfig curve.

Extension functions summary

For AnimatedFloat
Unit
AnimatedFloat.fling(startVelocity: Float, config: FlingConfig, onAnimationEnd: OnAnimationEnd? = null)

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

Top-level functions

FlingConfig

fun FlingConfig(
    anchors: List<Float>,
    animationSpec: AnimationSpec<Float> = SpringSpec(),
    decayAnimation: FloatDecayAnimationSpec = 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
animationSpec: AnimationSpec<Float> = SpringSpec() animation which will be used for animations
decayAnimation: FloatDecayAnimationSpec = ExponentialDecay() decay animation to be used to calculate closest point in the anchors set considering velocity.

defaultFlingConfig

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

Default FlingConfig curve.

Parameters
adjustTarget: (Float) -> TargetAnimation? = { null } callback to be called at the start of fling so the final value for fling can be adjusted

Extension functions

fling

fun AnimatedFloat.fling(
    startVelocity: Float,
    config: FlingConfig,
    onAnimationEnd: OnAnimationEnd? = null
): Unit

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

Parameters
startVelocity: Float Starting velocity of the fling animation
config: FlingConfig configuration that specifies fling behaviour
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.