Package-level declarations

Types

Link copied to clipboard

The receiver of an AnimatedContent's content.

Link copied to clipboard

The receiver of an AnimatedContent's transitionSpec: a segment of the container's transition, plus slides into and out of the container's edges, which need the container's size.

Link copied to clipboard

The receiver of an animated container's content.

Link copied to clipboard
class ContentTransform(val targetContentEnter: EnterTransition, val initialContentExit: ExitTransition, targetContentZIndex: Float = 0.0f, sizeTransform: SizeTransform? = SizeTransform())

How one content of an AnimatedContent replaces another: the target content's enter, the initial content's exit, their paint order, and how the container's size animates.

Link copied to clipboard

The state of an animated container's content between hidden and shown.

Link copied to clipboard
@Immutable
sealed class EnterTransition

How content appears: a fade, a slide, a scale, an expansion of its space, a scrim, or a combination built with plus.

Link copied to clipboard
@Immutable
sealed class ExitTransition

How content disappears: a fade, a slide, a scale, a shrink of its space, a scrim, or a combination built with plus.

Link copied to clipboard

Marks an experimental animation API. A later release may change its signature or behavior, or remove it.

Link copied to clipboard

How the two contents of an AnimatedContent are transformed during a deferred phase: the content of the announced state and the content on screen, each driven by its own MutableTransform.

Link copied to clipboard
class MutableTransform(veilMatchParentSize: Boolean = false, offsetVelocityProvider: () -> Point2D.Float? = null, block: TransformScope.(fullSize: Dimension) -> Unit? = null)

How the content of an animated container is transformed during a deferred phase, which a DeferredTransitionState begins with defer and ends with animateTo.

Link copied to clipboard
interface SizeTransform

How an AnimatedContent container's size animates from the initial content's size to the target content's size.

Link copied to clipboard
interface TransformScope

The transformations a MutableTransform block applies to the content during a deferred phase.

Properties

Link copied to clipboard

Animates a Color as a four-dimensional vector of its alpha and its three Oklab coordinates.

Link copied to clipboard

Animates a Dimension as a two-dimensional vector of its width and height.

Link copied to clipboard

Animates a Point as a two-dimensional vector of its x and y coordinates.

Functions

Link copied to clipboard
@RememberInComposition
fun Animatable(initialValue: Color): Animatable<Color, AnimationVector4D>

Holds a color that animates through Oklab, the space ColorToVector describes.

Link copied to clipboard
@Composable
fun <S> Transition<S>.animateColor(transitionSpec: @Composable Transition.Segment<S>.() -> FiniteAnimationSpec<Color> = { spring() }, label: String = "ColorAnimation", targetValueByState: @Composable (state: S) -> Color): State<Color>

Animates a color as part of this Transition, which owns the animation's lifetime.

@Composable
fun InfiniteTransition.animateColor(initialValue: Color, targetValue: Color, animationSpec: InfiniteRepeatableSpec<Color>, label: String = "ColorAnimation"): State<Color>

Animates a color from initialValue to targetValue and repeats for as long as this InfiniteTransition stays in the composition, restarting or reversing on each iteration according to the RepeatMode of animationSpec.

Link copied to clipboard
@Composable
fun animateColorAsState(targetValue: Color, animationSpec: AnimationSpec<Color> = colorDefaultSpring, label: String = "ColorAnimation", finishedListener: (Color) -> Unit? = null): State<Color>

Animates towards targetValue whenever it changes. A running animation continues from its current value towards the new target instead of restarting.

Link copied to clipboard
fun SwingModifier.animateContentSize(animationSpec: FiniteAnimationSpec<Dimension> = spring(stiffness = Spring.StiffnessMediumLow, visibilityThreshold = dimensionVisibilityThreshold()), alignment: Alignment = Alignment.TopStart, finishedListener: (initialValue: Dimension, targetValue: Dimension) -> Unit? = null): SwingModifier

Animates this component's size when the measured size of its content changes.

Link copied to clipboard
@Composable
fun <S> AnimatedContent(targetState: S, modifier: SwingModifier = SwingModifier, transitionSpec: AnimatedContentTransitionScope<S>.() -> ContentTransform = { ( fadeIn(animationSpec = tween(220, delayMillis = 90)) + scaleIn(initialScale = 0.92f, animationSpec = tween(220, delayMillis = 90)) ).togetherWith(fadeOut(animationSpec = tween(90))) }, contentAlignment: Alignment = Alignment.TopStart, label: String = "AnimatedContent", contentKey: (targetState: S) -> Any? = { it }, content: @Composable AnimatedContentScope.(targetState: S) -> Unit)

A container that animates between the contents of its states. When targetState changes, the new content animates in, the old content animates out, and the container's size animates between them.

Link copied to clipboard
@Composable
fun <S> Transition<S>.AnimatedContent(modifier: SwingModifier = SwingModifier, transitionSpec: AnimatedContentTransitionScope<S>.() -> ContentTransform = { ( fadeIn(animationSpec = tween(220, delayMillis = 90)) + scaleIn(initialScale = 0.92f, animationSpec = tween(220, delayMillis = 90)) ).togetherWith(fadeOut(animationSpec = tween(90))) }, contentAlignment: Alignment = Alignment.TopStart, contentKey: (targetState: S) -> Any? = { it }, content: @Composable AnimatedContentScope.(targetState: S) -> Unit)

A container that animates between the contents of this transition's states. Containers built on one transition animate together.

@Composable
fun <S> ConstrainedScope.AnimatedContent(targetState: S, modifier: SwingModifier = SwingModifier, transitionSpec: AnimatedContentTransitionScope<S>.() -> ContentTransform = { ( fadeIn(animationSpec = tween(220, delayMillis = 90)) + scaleIn(initialScale = 0.92f, animationSpec = tween(220, delayMillis = 90)) ).togetherWith(fadeOut(animationSpec = tween(90))) }, contentAlignment: Alignment = Alignment.TopStart, label: String = "AnimatedContent", contentKey: (targetState: S) -> Any? = { it }, content: @Composable AnimatedContentScope.(targetState: S) -> Unit)

A container inside a Foundation layout that animates between the contents of its states.

Link copied to clipboard
@Composable
fun AnimatedVisibility(visible: Boolean, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandIn(), exit: ExitTransition = shrinkOut() + fadeOut(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

A container that animates content in as visible becomes true and out as it becomes false.

@Composable
fun AnimatedVisibility(visibleState: MutableTransitionState<Boolean>, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandIn(), exit: ExitTransition = fadeOut() + shrinkOut(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

A container that animates content in and out as visibleState's target state changes. MutableTransitionState.isIdle tells whether every animation has finished, and MutableTransitionState.currentState where the running one started.

Link copied to clipboard
@Composable
context(parentScope: ConstrainedScope)
fun <T> Transition<T>.AnimatedVisibility(visible: (T) -> Boolean, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandIn(), exit: ExitTransition = shrinkOut() + fadeOut(), content: @Composable AnimatedVisibilityScope.() -> Unit)

A container that animates content in and out as this transition's state starts and stops satisfying visible. Containers built on one transition animate together.

@Composable
fun ColumnScope.AnimatedVisibility(visible: Boolean, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandVertically(), exit: ExitTransition = fadeOut() + shrinkVertically(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

A container that animates content in and out inside a Column, expanding and shrinking vertically only, so the column's width does not change.

@Composable
fun ColumnScope.AnimatedVisibility(visibleState: MutableTransitionState<Boolean>, modifier: SwingModifier = SwingModifier, enter: EnterTransition = expandVertically() + fadeIn(), exit: ExitTransition = shrinkVertically() + fadeOut(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

The MutableTransitionState counterpart of the Column overload.

@Composable
fun ConstrainedScope.AnimatedVisibility(visible: Boolean, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandIn(), exit: ExitTransition = shrinkOut() + fadeOut(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

A container inside a Foundation layout that animates content in and out as visible changes.

@Composable
fun ConstrainedScope.AnimatedVisibility(visibleState: MutableTransitionState<Boolean>, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandIn(), exit: ExitTransition = fadeOut() + shrinkOut(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

The MutableTransitionState counterpart of the Boolean overload inside a Foundation layout.

@Composable
fun RowScope.AnimatedVisibility(visible: Boolean, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandHorizontally(), exit: ExitTransition = fadeOut() + shrinkHorizontally(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

A container that animates content in and out inside a Row, expanding and shrinking horizontally only, so the row's height does not change.

@Composable
fun RowScope.AnimatedVisibility(visibleState: MutableTransitionState<Boolean>, modifier: SwingModifier = SwingModifier, enter: EnterTransition = expandHorizontally() + fadeIn(), exit: ExitTransition = shrinkHorizontally() + fadeOut(), label: String = "AnimatedVisibility", content: @Composable AnimatedVisibilityScope.() -> Unit)

The MutableTransitionState counterpart of the Row overload.

Link copied to clipboard
suspend fun ScrollState.animateScrollBy(dx: Int = 0, dy: Int = 0, animationSpec: AnimationSpec<Point> = spring(visibilityThreshold = pointVisibilityThreshold())): Point

Scrolls the pane dx to the right and dy down over time, from where it stands at this call, and returns how far it scrolled.

Link copied to clipboard
suspend fun ScrollState.animateScrollTo(x: Int = this.x, y: Int = this.y, animationSpec: AnimationSpec<Point> = spring(visibilityThreshold = pointVisibilityThreshold()))

Scrolls the pane to x, y over time, a step per frame, and returns once it arrives.

Link copied to clipboard
@Composable
fun <T> Crossfade(targetState: T, modifier: SwingModifier = SwingModifier, animationSpec: FiniteAnimationSpec<Float> = tween(), label: String = "Crossfade", content: @Composable (T) -> Unit)

A container that fades between the contents of its states. When targetState changes, the new content fades in and the old content fades out, both under animationSpec.

Link copied to clipboard
@Composable
fun <T> Transition<T>.Crossfade(modifier: SwingModifier = SwingModifier, animationSpec: FiniteAnimationSpec<Float> = tween(), contentKey: (targetState: T) -> Any? = { it }, content: @Composable (targetState: T) -> Unit)

A container that fades between the contents of this transition's states. Containers built on one transition animate together.

Link copied to clipboard
@Composable
fun <S> DeferredTransition<S>.DeferredAnimatedContent(modifier: SwingModifier = SwingModifier, transitionSpec: AnimatedContentTransitionScope<S>.() -> ContentTransform = { ( fadeIn(animationSpec = tween(220, delayMillis = 90)) + scaleIn(initialScale = 0.92f, animationSpec = tween(220, delayMillis = 90)) ).togetherWith(fadeOut(animationSpec = tween(90))) }, contentAlignment: Alignment = Alignment.TopStart, contentKey: (targetState: S) -> Any? = { it }, mutableTransformSpec: AnimatedContentTransitionScope<S>.() -> MutableContentTransform? = { null }, content: @Composable AnimatedContentScope.(targetState: S) -> Unit)

A container that animates between the contents of this deferred transition's states. During a deferred phase, both contents are transformed as mutableTransformSpec declares.

Link copied to clipboard
@Composable
context(parentScope: ConstrainedScope)
fun <T> DeferredTransition<T>.DeferredAnimatedVisibility(visible: (T) -> Boolean, modifier: SwingModifier = SwingModifier, enter: EnterTransition = fadeIn() + expandIn(), exit: ExitTransition = shrinkOut() + fadeOut(), mutableTransform: MutableTransform? = null, content: @Composable AnimatedVisibilityScope.() -> Unit)

A container that animates content in and out as this deferred transition's state starts and stops satisfying visible. During a deferred phase, mutableTransform transforms the content.

Link copied to clipboard

The size change below which a Dimension animation is considered finished: one unit on each axis.

Link copied to clipboard
@Stable
fun expandHorizontally(animationSpec: FiniteAnimationSpec<Dimension> = DEFAULT_SIZE_SPRING, expandFrom: Alignment.Horizontal = Alignment.End, clip: Boolean = true, initialWidth: (fullWidth: Int) -> Int = { 0 }): EnterTransition

Expands the width the content is given, from initialWidth to the content's full width, keeping the full height. The content is centered vertically.

Link copied to clipboard
@Stable
fun expandIn(animationSpec: FiniteAnimationSpec<Dimension> = DEFAULT_SIZE_SPRING, expandFrom: Alignment = Alignment.BottomEnd, clip: Boolean = true, initialSize: (fullSize: Dimension) -> Dimension = { Dimension(0, 0) }): EnterTransition

Expands the space the content is given, from initialSize to the content's full size.

Link copied to clipboard
@Stable
fun expandVertically(animationSpec: FiniteAnimationSpec<Dimension> = DEFAULT_SIZE_SPRING, expandFrom: Alignment.Vertical = Alignment.Bottom, clip: Boolean = true, initialHeight: (fullHeight: Int) -> Int = { 0 }): EnterTransition

Expands the height the content is given, from initialHeight to the content's full height, keeping the full width. The content is centered horizontally.

Link copied to clipboard
@Stable
fun fadeIn(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), initialAlpha: Float = 0.0f): EnterTransition

Fades the content in, from initialAlpha to full opacity.

Link copied to clipboard
@Stable
fun fadeOut(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), targetAlpha: Float = 0.0f): ExitTransition

Fades the content out, from full opacity to targetAlpha.

Link copied to clipboard
fun MutableContentTransform(initialVeilMatchParentSize: Boolean = false, targetVeilMatchParentSize: Boolean = false, initialOffsetVelocityProvider: () -> Point2D.Float? = null, targetOffsetVelocityProvider: () -> Point2D.Float? = null, block: MutableContentTransform.() -> Unit = {}): MutableContentTransform

A MutableContentTransform with block applied to it.

Link copied to clipboard

The offset change below which a Point animation is considered finished: one unit on each axis.

Link copied to clipboard
@Stable
fun scaleIn(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), initialScale: Float = 0.0f, transformOrigin: TransformOrigin = TransformOrigin.Center): EnterTransition

Scales the content in, from initialScale to its own size, around transformOrigin.

Link copied to clipboard
@Stable
fun scaleOut(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), targetScale: Float = 0.0f, transformOrigin: TransformOrigin = TransformOrigin.Center): ExitTransition

Scales the content out, from its own size to targetScale, around transformOrigin.

Link copied to clipboard
@Stable
fun shrinkHorizontally(animationSpec: FiniteAnimationSpec<Dimension> = DEFAULT_SIZE_SPRING, shrinkTowards: Alignment.Horizontal = Alignment.End, clip: Boolean = true, targetWidth: (fullWidth: Int) -> Int = { 0 }): ExitTransition

Shrinks the width the content is given, from the content's full width to targetWidth, keeping the full height. The content is centered vertically.

Link copied to clipboard
@Stable
fun shrinkOut(animationSpec: FiniteAnimationSpec<Dimension> = DEFAULT_SIZE_SPRING, shrinkTowards: Alignment = Alignment.BottomEnd, clip: Boolean = true, targetSize: (fullSize: Dimension) -> Dimension = { Dimension(0, 0) }): ExitTransition

Shrinks the space the content is given, from the content's full size to targetSize.

Link copied to clipboard
@Stable
fun shrinkVertically(animationSpec: FiniteAnimationSpec<Dimension> = DEFAULT_SIZE_SPRING, shrinkTowards: Alignment.Vertical = Alignment.Bottom, clip: Boolean = true, targetHeight: (fullHeight: Int) -> Int = { 0 }): ExitTransition

Shrinks the height the content is given, from the content's full height to targetHeight, keeping the full width. The content is centered horizontally.

Link copied to clipboard
fun SizeTransform(clip: Boolean = true, sizeAnimationSpec: (initialSize: Dimension, targetSize: Dimension) -> FiniteAnimationSpec<Dimension> = { _, _ -> spring(stiffness = Spring.StiffnessMediumLow, visibilityThreshold = dimensionVisibilityThreshold()) }): SizeTransform

Builds a SizeTransform with the provided clip and sizeAnimationSpec.

Link copied to clipboard
@Stable
fun slideIn(animationSpec: FiniteAnimationSpec<Point> = DEFAULT_SLIDE_SPRING, initialOffset: (fullSize: Dimension) -> Point): EnterTransition

Slides the content in, from initialOffset to its place in the container.

Link copied to clipboard
@Stable
fun slideInHorizontally(animationSpec: FiniteAnimationSpec<Point> = DEFAULT_SLIDE_SPRING, initialOffsetX: (fullWidth: Int) -> Int = { -it / 2 }): EnterTransition

Slides the content in horizontally, from initialOffsetX to its place in the container.

Link copied to clipboard
@Stable
fun slideInVertically(animationSpec: FiniteAnimationSpec<Point> = DEFAULT_SLIDE_SPRING, initialOffsetY: (fullHeight: Int) -> Int = { -it / 2 }): EnterTransition

Slides the content in vertically, from initialOffsetY to its place in the container.

Link copied to clipboard
@Stable
fun slideOut(animationSpec: FiniteAnimationSpec<Point> = DEFAULT_SLIDE_SPRING, targetOffset: (fullSize: Dimension) -> Point): ExitTransition

Slides the content out, from its place in the container to targetOffset.

Link copied to clipboard
@Stable
fun slideOutHorizontally(animationSpec: FiniteAnimationSpec<Point> = DEFAULT_SLIDE_SPRING, targetOffsetX: (fullWidth: Int) -> Int = { -it / 2 }): ExitTransition

Slides the content out horizontally, from its place in the container to targetOffsetX.

Link copied to clipboard
@Stable
fun slideOutVertically(animationSpec: FiniteAnimationSpec<Point> = DEFAULT_SLIDE_SPRING, targetOffsetY: (fullHeight: Int) -> Int = { -it / 2 }): ExitTransition

Slides the content out vertically, from its place in the container to targetOffsetY.

Link copied to clipboard

Combines this enter transition with exit into a ContentTransform, as an AnimatedContent transitionSpec returns.

Link copied to clipboard
@Stable
fun unveilIn(animationSpec: FiniteAnimationSpec<Color> = spring(stiffness = Spring.StiffnessMediumLow), initialColor: Color = DefaultVeilColor, matchParentSize: Boolean = false): EnterTransition

Unveils the content as it enters: a scrim of initialColor over it animates to fully transparent.

Link copied to clipboard
@Stable
fun veilOut(animationSpec: FiniteAnimationSpec<Color> = spring(stiffness = Spring.StiffnessMediumLow), targetColor: Color = DefaultVeilColor, matchParentSize: Boolean = false): ExitTransition

Veils the content as it leaves: a scrim over it animates from fully transparent to targetColor.