# Motion

Transitions run in the native runtime: TSX sends the new target once and Rust interpolates, lays out and schedules frames, with no JavaScript timer or per-frame render.

## Transitions

```tsx title="panel.tsx"
<View
  id="details-panel"
  motionFrom={{ opacity: 0, width: 240 }}
  onTransitionEnd={({ property }) => console.log(`${property} finished`)}
  style={{
    width: expanded ? 420 : 280,
    opacity: expanded ? 1 : 0.72,
    radius: 16,
    transition: {
      width: { duration: 220, easing: "easeOut" },
      opacity: { duration: 160, easing: "linear" },
      radius: { duration: 220, easing: "easeOut" },
    },
  }}
/>
```

| Option | Values |
| --- | --- |
| Numeric properties | `width`, `height`, `top`, `right`, `bottom`, `left`, `opacity`, `radius`. |
| Also animated | `background` and gradients with the same shape, colors, `boxShadow` and `transform`. |
| `easing` | `linear`, `ease`, `easeIn`, `easeOut`, `easeInOut`. |
| `duration`, `delay` | Milliseconds. |
| `transition: { all: … }` | One timing for every property. |

Changing a target mid-flight retargets from the current value, so nothing jumps back. `motionFrom` only applies when the native node is first created; besides the numeric properties it takes a `transform` (an object or a CSS string such as `"translateY(12px) scale(0.98)"`), as do `AnimatePresence`'s `enter` and `exit`. The system reduced-motion setting is honored natively.

## Looping animations

`style.animation` is CSS `animation` over two keyframes: `from` names the animated properties (any of the transition properties: opacity, sizes, `transform`, colours and gradients, shadows), `to` defaults to the style's own value. `iterations` is a count or `"infinite"`, `direction: "alternate"` plays every other run backwards, plus `duration`, `delay` and `easing`. Rust drives the frames; an unchanged animation keeps running through re-renders, a changed one starts over, removing it stops it.

```tsx title="skeleton.tsx"
// skeleton shimmer: forever, back and forth
<View style={{ height: 120, radius: 12, background: theme.colors.muted,
  animation: { from: { opacity: 0.45 }, to: { opacity: 1 }, duration: 900, iterations: "infinite", direction: "alternate", easing: "easeInOut" } }} />

// slow hero zoom
<Image src={cover} style={{ animation: { from: { transform: "scale(1)" }, to: { transform: "scale(1.08)" }, duration: 20000, iterations: "infinite", direction: "alternate", easing: "linear" } }} />

// enter from below
<View motionFrom={{ opacity: 0, transform: "translateY(12px)" }}
  style={{ transition: { opacity: { duration: 240 }, transform: { duration: 240, easing: "easeOut" } } }} />
```

## Exit animations

A removed node disappears at once. To animate it out, keep an `AnimatePresence` boundary rendered and toggle `present`:

```tsx title="details.tsx"
<AnimatePresence
  id="details-presence"
  present={detailsOpen}
  enter={{ opacity: 0 }}
  exit={{ opacity: 0 }}
  transition={{ opacity: { duration: 180, easing: "easeOut" } }}
>
  <Card id="details-card" style={{ opacity: 1 }}>
    <Text>Project details</Text>
  </Card>
</AnimatePresence>
```

See [AnimatePresence](https://tarve.dev/docs/components/AnimatePresence.md). In tests, `advanceMotion(ms)` moves the motion clock deterministically (see [Automation](https://tarve.dev/docs/automation.md)).

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/motion · Index for agents: https://tarve.dev/llms.txt
