SwipeToDismissBoxState

Class

Android
public class SwipeToDismissBoxState(
    animationSpec: AnimationSpec<Float> = SwipeToDismissBoxDefaults.AnimationSpec,
    confirmStateChange: (SwipeToDismissValue) -> Boolean = { true },
)

State for BasicSwipeToDismissBox.

Parameters

animationSpecThe default animation that will be used to animate to a new state.
confirmStateChangecallback invoked to confirm or veto a pending state change.

Functions

public fun requireOffset(): Float

Require the current offset. This method should always be used instead of using the offset field, unless the access to the uninitialised value is required.

The offset shows how far the foreground content was swiped from its original position.

public suspend fun snapTo(targetValue: SwipeToDismissValue): Unit

Set the state without any animation and suspend until it's set

Parameters

targetValueThe new target value to set currentValue to.

Companion Object