Components / Animations / Puzzle Transition
Puzzle Transition
Content changes by moving to the next piece of one jigsaw. Every page is a piece whose outline lies just outside its edge, so at rest the page is only the page. On a change the camera pulls back a little, far enough to show the outline; the pages slide across with the arm of this piece locked into the next; and the camera closes in on the next page. Two pieces that lock share their cut, so it is one line, and the arm is a real tab’s shape: a short neck and a round head twice as wide. Each step moves the camera on the minimum-jerk law, x(τ) = 10τ³ − 15τ⁴ + 6τ⁵, solved from wherever it is, so changing back partway turns the step in progress round and runs the rest backwards.
Model
s: 1 → zoom, x: 0 → d, s: zoom → 1, each 10τ³ − 15τ⁴ + 6τ⁵the camera pulls back, slides and closes in, one step after another, each on the minimum-jerk law, τ = t/T · the slide d = A + 2m + t + 2.39·r: a page A, a margin m either side, the line t and the arm’s reach, r its head radius
Props
| Property | Type | Default | Description |
|---|---|---|---|
transitionKey | string | number | — | Changing this sends the camera to the next page, which lies beside the page on show as the jigsaw piece it locks into: it pulls back, slides and closes in. Changed back before it arrives, it goes back the way it came; changed again while it moves, the next page is brought once it has arrived. |
direction | 'left' | 'right' | 'up' | 'down' | 'left' | The way the pages move. The next page comes in from the opposite side. |
duration | number | 1400 | The whole move, ms: pulling back and closing in take a fifth each, the slide the rest. Held to at least 300; anything that is not a finite number falls back to 1400. |
zoom | number | 0.85 | The scale the camera pulls back to before the slide, which brings the outline into view. 1 for no pull back; held to at least 0.3. |
knobs | number | 1 | How many arms are cut along the joining edge, 1 to 8. |
margin | number | 12 | How far outside a page's edge its outline lies, px, measured to the line's edge. At rest it is out of view. |
thickness | number | 6 | The line's width, px, the same at any scale. |
color | string | 'currentColor' | The line's colour. Any CSS colour; by default the text colour. |
onComplete | () => void | — | Called once the camera has arrived at the next page, or gone back to the one on show. |
children | ReactNode | — | What is showing for the current transitionKey. |