SwipeToDismissBoxState

constructor(initialValue: SwipeToDismissBoxValue, positionalThreshold: (totalDistance: Float) -> Float)

State of the SwipeToDismissBox composable.

Parameters

initialValue

The initial value of the state.

positionalThreshold

The positional threshold to be used when calculating the target state while a swipe is in progress and when settling after the swipe ends. This is the distance from the start of a transition. It will be, depending on the direction of the interaction, added or subtracted from/to the origin offset. It should always be a positive value.


constructor(initialValue: SwipeToDismissBoxValue, density: Density, confirmValueChange: (SwipeToDismissBoxValue) -> Boolean = { true }, positionalThreshold: (totalDistance: Float) -> Float)

Deprecated

confirmValueChange is deprecated without replacement. Rather than relying on a callback to veto state changes, the anchor set should not include disallowed anchors. See androidx.compose.foundation.samples.AnchoredDraggableDynamicAnchorsSample for an example of using dynamic anchors over confirmValueChange.

Replace with

SwipeToDismissBoxState(initialValue, density, positionalThreshold)

State of the SwipeToDismissBox composable.

Parameters

initialValue

The initial value of the state.

density

The density that this state can use to convert values to and from dp.

confirmValueChange

Optional callback invoked to confirm or veto a pending state change.

positionalThreshold

The positional threshold to be used when calculating the target state while a swipe is in progress and when settling after the swipe ends. This is the distance from the start of a transition. It will be, depending on the direction of the interaction, added or subtracted from/to the origin offset. It should always be a positive value.