Composable Function

rememberSwipeToDismissBoxState

Create and remember a SwipeToDismissBoxState.

rememberSwipeToDismissBoxState

Source set: Common
@Composable
public fun rememberSwipeToDismissBoxState(
    initialValue: SwipeToDismissBoxValue = SwipeToDismissBoxValue.Settled,
    positionalThreshold: (totalDistance: Float) -> Float =
        SwipeToDismissBoxDefaults.positionalThreshold,
): SwipeToDismissBoxState

Create and remember a SwipeToDismissBoxState.

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.

rememberSwipeToDismissBoxState

Source set: Common
@Composable
@Deprecated(
    message = ConfirmValueChangeDeprecated,
    level = DeprecationLevel.WARNING,
    replaceWith = ReplaceWith("rememberSwipeToDismissBoxState(initialValue, positionalThreshold)"),
)
public fun rememberSwipeToDismissBoxState(
    initialValue: SwipeToDismissBoxValue = SwipeToDismissBoxValue.Settled,
    confirmValueChange: (SwipeToDismissBoxValue) -> Boolean = { true },
    positionalThreshold: (totalDistance: Float) -> Float =
        SwipeToDismissBoxDefaults.positionalThreshold,
): SwipeToDismissBoxState

Create and remember a SwipeToDismissBoxState.

Parameters

initialValue The initial value of the state.
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.
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: