# `Visualize.Hooks.Motion`
[🔗](https://github.com/dcoai/Visualize/blob/v0.8.3/lib/visualize/hooks/motion.ex#L1)

The frame loop the canvas hooks move a style's motion in (spec/10 §4.5, spec/14 §3.10,
D-176).

A canvas has no CSS, so the hook that draws it runs a style's `transition`: each element
of a moving mark is drawn inside a motion span (spec/09 §3.3.5) naming its identity and
its transition, and `VisualizeMotion` keeps, per identity, draw and context property, the
value the canvas last showed. When a new stream draws an identity with another target,
the value moves from what is shown to the target along the span's samples — colors in
OKLab — and the hook replays its stream in `requestAnimationFrame` until nothing moves.
A stream without a span is drawn once and requests no frame. A reader who prefers reduced
motion sees every target at once.

`CanvasChart` (`Visualize.Hooks.Canvas`) and `CanvasBinaryChart`
(`Visualize.Hooks.CanvasBinary`) use it; the bundle defines it once and does not export it.

# `js_hook`

```elixir
@spec js_hook() :: String.t()
```

Returns the JavaScript source of `MotionHook` (spec/10 §20, spec/14 §3.12, #678): the
hook around a chart that plays each exit — a copy of a gone element, recorded before the
patch that removed it, played in an overlay over the chart — and restarts each enter a
positional patch handed to another identity.

# `js_motion`

```elixir
@spec js_motion() :: String.t()
```

Returns the JavaScript source of `VisualizeMotion`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
