SwipeableState

open class SwipeableState<T>(initialValue: T, animationSpec: AnimationSpec<Float> = AnimationSpec, val confirmStateChange: (newValue: T) -> Boolean = { true })

State of the swipeable 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 SwipeableState with the default animation clock, use rememberSwipeableState.

Parameters

initialValue

The initial value of the state.

animationSpec

The default animation that will be used to animate to a new state.

confirmStateChange

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

Constructors

Link copied to clipboard
constructor(initialValue: T, animationSpec: AnimationSpec<Float> = AnimationSpec, confirmStateChange: (newValue: T) -> Boolean = { true })

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val confirmStateChange: (newValue: T) -> Boolean
Link copied to clipboard

The current value of the state.

Link copied to clipboard

Whether the state is currently animating.

Link copied to clipboard

The current position (in pixels) of the swipeable.

Link copied to clipboard

The amount by which the swipeable has been swiped past its bounds.

Link copied to clipboard

The target value of the state.

Functions

Link copied to clipboard
suspend fun animateTo(targetValue: T, anim: AnimationSpec<Float> = animationSpec)

Set the state to the target value by starting an animation.