public class SwipeToDismissBoxState(
animationSpec: AnimationSpec<Float> = SwipeToDismissBoxDefaults.AnimationSpec,
confirmStateChange: (SwipeToDismissValue) -> Boolean = { true },
)
State for BasicSwipeToDismissBox.
Parameters
| animationSpec | The default animation that will be used to animate to a new state. |
| confirmStateChange | callback invoked to confirm or veto a pending state change. |
Properties
currentValue
public val currentValue: SwipeToDismissValue
The current value of the state.
Before and during a swipe, corresponds to SwipeToDismissValue.Default, then switches to SwipeToDismissValue.Dismissed if the swipe has been completed.
targetValue
public val targetValue: SwipeToDismissValue
The target value of the state.
If a swipe is in progress, this is the value that the state would animate to if the swipe finished. If an animation is running, this is the target value of that animation. Finally, if no swipe or animation is in progress, this is the same as the currentValue.
offset
public val offset: Float
The current offset, or Float.NaN if it has not been initialized yet. Consider using requireOffset() method instead - this field should only be used when the access to the uninitialised value is required.
The offset shows how far the foreground content was swiped from its original position.
isAnimationRunning
public val isAnimationRunning: Boolean
Whether the state is currently animating.
Functions
requireOffset
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.
snapTo
public suspend fun snapTo(targetValue: SwipeToDismissValue): Unit
Set the state without any animation and suspend until it's set
Parameters
| targetValue | The new target value to set currentValue to. |