Swipeable V2State
State of the swipeableV2 modifier.
This contains necessary information about any ongoing swipe or animation and provides methods to change the state either immediately or by starting an animation. To create and remember a SwipeableV2State use rememberSwipeableV2State.
Parameters
The initial value of the state.
The default animation that will be used to animate to a new state.
Optional callback invoked to confirm or veto a pending state change.
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. See the fractionalPositionalThreshold and fixedPositionalThreshold methods.
The velocity threshold (in dp per second) that the end velocity has to exceed in order to animate to the next state, even if the positionalThreshold has not been reached.
Constructors
Properties
The current value of the SwipeableV2State.
Whether an animation is currently in progress.
The velocity of the last known animation. Gets reset to 0f when an animation completes successfully, but does not get reset when an animation gets interrupted. You can use this value to provide smooth reconciliation behavior when re-targeting an animation.
The maximum offset this state can reach. This will be the biggest anchor, or Float.POSITIVE_INFINITY if the anchors are not initialized yet.
The minimum offset this state can reach. This will be the smallest anchor, or Float.NEGATIVE_INFINITY if the anchors are not initialized yet.
The fraction of the progress going from currentValue to targetValue, within 0f..1f bounds.
The target value. This is the closest value to the current offset (taking into account positional thresholds). If no interactions like animations or drags are in progress, this will be the current value.
Functions
Animate to a targetValue. If the targetValue is not in the set of anchors, the currentValue will be updated to the targetValue without updating the offset.
Swipe by the delta, coerce it in the bounds and dispatch it to the draggableState.
Whether the value has an anchor associated with it.
Require the current offset.
Snap to a targetValue without any animation. If the targetValue is not in the set of anchors, the currentValue will be updated to the targetValue without updating the offset.