Skip to Content
CrowCrow

Motion, Shared Elements & Predictive Back

Analytic velocity-preserving springs, AnimatedVisibility exit ghosts, layer-phase graphicsLayer, shared-element flights, and 1:1 predictive back.

crow-motion is Crow's platform-free animation engine. Springs are analytic (closed-form position and velocity at any timestamp), interruptible by default, and backed by Lane.Immediate external signals so animations never stall during async transitions and bypass the reactive tree walk completely.

Analytic Springs & animateFloat

Define springs with intuitive duration and bounce parameters (no manual stiffness/damping math needed):

var expanded by signal(false)
val progress = animateFloat(spring = Spring.Bouncy) {
    if (expanded) 1f else 0f
}

Box(
    Modifier
        .size(96.dp)
        .graphicsLayer {
            val p = progress.value
            scale = 1f + p * 0.15f
            rotation = p * 12f
        }
        .clickable { expanded = !expanded },
)
  • Nothing animates on the first frame: animateFloat starts settled at its initial target.
  • Velocity-preserving retargets: Flip expanded mid-flight and the spring preserves exact position and momentum — no jumps, no discontinuities.
  • Layers-only frames: When a Choreographer tick writes only graphicsLayer properties (alpha, scaleX, scaleY, translationX, translationY, rotation), Crow UI updates the RenderNode directly without visiting the node tree.

For imperative gesture-driven motion, use Animatable(initial) with animateTo(...), snapTo(...), and velocity.

AnimatedVisibility & Exit Ghosts

AnimatedVisibility keeps exiting subtrees alive as exit ghosts — inert to touch input while animating out, and smoothly revived mid-exit with their velocity and state intact if the condition flips back:

var showBanner by signal(false)

AnimatedVisibility(visible = showBanner, transition = VisibilityTransition.Rise) {
    Surface(Modifier.fillMaxWidth()) {
        Text("Springs in and out on GPU layers — tap again mid-flight to reverse.")
    }
}

Shared-Element Flights (Modifier.sharedElement)

Tag matching elements across two screens (such as a card's artwork in a grid and the hero banner on its detail screen) with the same key:

// On HomeScreen
Image(
    source = pokemon.imageUrl,
    contentDescription = pokemon.name,
    modifier = Modifier
        .size(120.dp)
        .sharedElement("pokemon-${pokemon.id}"),
)

// On DetailsScreen
Image(
    source = pokemon.imageUrl,
    contentDescription = pokemon.name,
    modifier = Modifier
        .size(220.dp)
        .sharedElement("pokemon-${pokemon.id}"),
)

Crow animates the bounds and position seamlessly between destinations — and turns around smoothly mid-flight if the user presses back early.

Predictive Back (1:1 Finger Tracking)

Crow integrates natively with Android's OnBackAnimationCallback (API 34+) and BackDispatcher:

  • Dragging from the screen edge wakes the destination underneath (inert) and drives NavTransition.seek(progress) 1:1 with the finger.
  • Releasing to commit hands the gesture's exact velocity into the settling spring.
  • Cancelling springs both screens cleanly back to rest.
  • Register custom preview-aware handlers anywhere with onBack(preview = { ... }) { ... }. When nothing consumes back, Crow yields immediately so the OS back-to-home animation plays naturally.

How is this guide?

On this page