DeferredTransitionState


A TransitionState that supports a deferred phase before the automatic transition begins.

This state is designed for scenarios where a transition should be held in an intermediate, manually-controlled state (e.g., during a predictive back gesture) before proceeding to its final target.

While in the deferred phase (initiated by defer), the transition holds the new target as a pendingTargetState. The actual targetState remains unchanged, keeping the transition in its current visual state. Once animateTo is called, the pendingTargetState is cleared and the transition proceeds to the new targetState, triggering its automatic animations.

Summary

Public constructors

<S : Any?> DeferredTransitionState(initialState: S)
Cmn

Public functions

Unit
animateTo(targetState: S)

Clears the pendingTargetState and updates the targetState to the provided targetState, ending the deferred phase and starting the automatic transition animation.

Cmn
Unit
defer(targetState: S)

Updates the pendingTargetState and initiates the deferred phase.

Cmn

Public properties

open S

Current state of the transition.

Cmn
S?

The target state that the transition will eventually animate to once the deferred phase ends.

Cmn
open S

Target state of the transition.

Cmn

Public constructors

DeferredTransitionState

<S : Any?> DeferredTransitionState(initialState: S)
Parameters
initialState: S

The initial state of the transition.

Public functions

animateTo

fun animateTo(targetState: S): Unit

Clears the pendingTargetState and updates the targetState to the provided targetState, ending the deferred phase and starting the automatic transition animation.

Note: The targetState provided here does not need to match the previous pendingTargetState. If a different state is provided, the transition will animate directly to this new state, bypassing the previously deferred target.

Parameters
targetState: S

The final target state for the transition.

defer

fun defer(targetState: S): Unit

Updates the pendingTargetState and initiates the deferred phase.

During this phase, the transition's targetState remains unchanged, keeping the transition in its current visual state. However, the new target is exposed via pendingTargetState, signaling to transition-aware components that a state change is pending. They can then use this information to perform early setup or apply custom logic for the pending state before the automatic transition is eventually started via animateTo.

If defer is called while an animation is already in progress (i.e., currentState != targetState), the animation will continue toward its current targetState while pendingTargetState is set. This allows components to respond to the pending state early, potentially concurrently with the ongoing animation.

Parameters
targetState: S

The state the transition should eventually animate to.

Public properties

currentState

open val currentState: S

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

pendingTargetState

val pendingTargetState: S?

The target state that the transition will eventually animate to once the deferred phase ends.

This value is set when defer is called and cleared when animateTo is called, at which point targetState will be updated to the new state.

targetState

open val targetState: S

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