SeekableTransitionState

class SeekableTransitionState<S>(initialState: S) : TransitionState<S>

A TransitionState that can manipulate the progress of the Transition by seeking with seekTo or animating with animateTo.

A SeekableTransitionState can only be used with one Transition instance. Once assigned, it cannot be reassigned to a different Transition instance.

Constructors

Link copied to clipboard
constructor(initialState: S)

Properties

Link copied to clipboard
open override var currentState: S

Current state of the transition. If there is an active transition, currentState and targetState are different.

Link copied to clipboard
@get:FloatRange(from = 0.0, to = 1.0)
var fraction: Float

The progress of the transition from currentState to targetState as a fraction of the entire duration.

Link copied to clipboard
open override var targetState: S

Target state of the transition. If this is the same as currentState, no transition is active.

Functions

Link copied to clipboard
suspend fun animateTo(targetState: S = this.targetState, animationSpec: FiniteAnimationSpec<Float>? = null)

Updates the current targetState to targetState and begins an animation to the new state. If the current targetState is the same as targetState then the current transition animation is continued. If a previous transition was interrupted, currentState is changed to the former targetState and the start values are animated toward the former targetState.

Link copied to clipboard
suspend fun seekTo(@FloatRange(from = 0.0, to = 1.0) fraction: Float, targetState: S = this.targetState)

Starts seeking the transition to targetState with fraction used to indicate the progress towards targetState. If the previous targetState was already targetState then seekTo only stops any current animation towards that state and snaps the fraction to the new value. Otherwise, the currentState is changed to the former targetState and targetState is changed to targetState and an animation is started, moving the start values towards the former targetState. This will return when the initial values have reached currentState and the fraction has been reached.

Link copied to clipboard
suspend fun snapTo(targetState: S)

Sets currentState and targetState to targetState and snaps all values to those at that state. The transition will not have any animations running after running snapTo.