animateToWithDecay

suspend fun <T> UnstyledAnchoredDraggableState<T>.animateToWithDecay(targetValue: T, velocity: Float): Float

Attempt to animate using decay Animation to a targetValue. If the velocity is high enough to get to the target offset, we'll use UnstyledAnchoredDraggableState.decayAnimationSpec to get to that offset and return the consumed velocity. If the velocity is not high enough, we'll use UnstyledAnchoredDraggableState.snapAnimationSpec to reach the target offset.

If the targetValue is not in the set of anchors, UnstyledAnchoredDraggableState.currentValue will be updated ro the targetValue without updating the offset.

Return

The velocity consumed in the animation

Parameters

targetValue

The target value of the animation

velocity

The velocity the animation should start with

Throws

CancellationException

if the interaction interrupted bt another interaction like a gesture interaction or another programmatic interaction like animateTo or snapTo call.