Class

SharedTransitionScope.SharedContentState

SharedContentState is designed to allow access of the properties of sharedBounds/sharedElement, such as whether a match of the same key has been found in the SharedTransitionScope, its clipPathInOverlay and parentSharedContentState if there is a parent sharedBounds in the layout tree.

Common
public class SharedContentState
    internal constructor(
        public val key: Any,
        config: SharedContentConfig = SharedTransitionDefaults.SharedContentConfig,
    )

SharedContentState is designed to allow access of the properties of sharedBounds/sharedElement, such as whether a match of the same key has been found in the SharedTransitionScope, its clipPathInOverlay and parentSharedContentState if there is a parent sharedBounds in the layout tree.

Functions

prepareTransitionWithInitialVelocity

public fun prepareTransitionWithInitialVelocity(initialVelocity: Velocity)

prepareTransitionWithInitialVelocity sets up the initial velocity for the upcoming shared element transition. This function should be called during the gesture handling to allow the system to acquire the animation start time in the next (i.e. earliest) animation frame to ensure a smooth velocity handoff.

The velocity will used for both incoming and outgoing shared content defined with the same key once shared element transition starts. The animationSpec used to animate the momentum will be the same as what is used by the incoming shared element's bounds transform to keep consistent motion. If the incoming shared element uses a duration-based animation, a default spring will be used instead.

Note: This function will have no effect if the shared element is not enabled (i.e. SharedContentConfig.isEnabled is false). This velocity will only apply to the next shared element transition.

Parameters

initialVelocity The velocity from the gesture system (e.g., from onDragEnd).