AnimatedContentTransitionScope

Interface

Common
public sealed interface AnimatedContentTransitionScope<S> : Transition.Segment<S>

AnimatedContentTransitionScope provides functions that are convenient and only applicable in the context of AnimatedContent, such as slideIntoContainer and slideOutOfContainer.

Functions

public infix fun ContentTransform.using(sizeTransform: SizeTransform?): ContentTransform

Customizes the SizeTransform of a given ContentTransform. For example:

public fun slideIntoContainer(
        towards: SlideDirection,
        animationSpec: FiniteAnimationSpec<IntOffset> =
            spring(visibilityThreshold = IntOffset.VisibilityThreshold),
        initialOffset: (offsetForFullSlide: Int) -> Int = { it },
    ): EnterTransition

This defines a horizontal/vertical slide-in that is specific to AnimatedContent from the edge of the container. The offset amount is dynamically calculated based on the current size of the AnimatedContent and its content alignment. This offset (may be positive or negative based on the direction of the slide) is then passed to initialOffset. By default, initialOffset will be using the offset calculated from the system to slide the content in. slideIntoContainer is a convenient alternative to slideInHorizontally and slideInVertically when the incoming and outgoing content differ in size. Otherwise, it would be equivalent to slideInHorizontally and slideInVertically with an offset of the full width/height.

towards specifies the slide direction. Content can be slided into the container towards SlideDirection.Left, SlideDirection.Right, SlideDirection.Up and SlideDirection.Down.

animationSpec defines the animation that will be used to animate the slide-in.

public fun slideOutOfContainer(
        towards: SlideDirection,
        animationSpec: FiniteAnimationSpec<IntOffset> =
            spring(visibilityThreshold = IntOffset.VisibilityThreshold),
        targetOffset: (offsetForFullSlide: Int) -> Int = { it },
    ): ExitTransition

This defines a horizontal/vertical exit transition to completely slide out of the AnimatedContent container. The offset amount is dynamically calculated based on the current size of the AnimatedContent and the new target size. This offset gets passed to targetOffset lambda. By default, targetOffset uses this offset as is, but it can be customized to slide a distance based on the offset. slideOutOfContainer is a convenient alternative to slideOutHorizontally and slideOutVertically when the incoming and outgoing content differ in size. Otherwise, it would be equivalent to slideOutHorizontally and slideOutVertically with an offset of the full width/height.

towards specifies the slide direction. Content can be slided out of the container towards SlideDirection.Left, SlideDirection.Right, SlideDirection.Up and SlideDirection.Down.

animationSpec defines the animation that will be used to animate the slide-out.