Zoom Through
A dark disc is born in the center of the screen, grows while losing its roundness until it swallows everything, the page changes in the dark, then it shrinks back on the new one: a dive toward the center in 1.2 s, animated in transform: scale() only — CSS + 1.5 KB of JavaScript.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Transitions has 52 effects, including 9 free. Explore the category →
3 usage examples



How it works
The .zoom-through-overlay layer is a box as large as the .transition-preview screen, set above both pages (z-index: 10): colored #0a0a0f, rounded with border-radius: 50% (so an ellipse) and shrunk to nothing by transform: scale(0).
On click, the layer gets .animating and plays @keyframes zoomThrough over 1.2 s ease-in-out: scale(0) and 50% rounding at the start, scale(3) and no rounding at 40%, held until 60%, then back. The ellipse grows from the center (a transform's default origin) while turning into a rectangle: as soon as it is bigger than the screen, everything is black, from 0.48 s to 0.72 s at least. At 0.6 s, the script toggles .is-b on .transition-preview; the shape then shrinks back over B. Only transform and border-radius change: layout is never recomputed, which keeps the dive smooth on a kiosk or a modest screen.
After the dive, B stays shown; the next click dives again and brings A back. At the moment of the swap, scale(3) was read in each of the three engines. A variant in the category draws the same shape by animating width and height; this one stays in transform.
Accessibility
- Reduced motion: a zoom toward the center is one of the motions that bothers sensitive people most; under
prefers-reduced-motion: reduce, the dive is therefore removed and the pages take over from each other with a 150 ms fade (measured: layer still, B visible within 250 ms). - Keyboard and screen readers: the trigger reuses Fade Through's (fx-0685) and focus never leaves the button during the zoom. The hidden page is not read; for a countdown that must be announced, put
aria-live="polite"on.transition-preview.
Browser compatibility
CSS (@keyframes on transform: scale() and border-radius, inset) + 1.5 KB of JavaScript, no dependency. Measured in Chromium 151, Firefox 153 and WebKit 26.5: layer at scale(3) at swap time, page B held, back to A on the next click, focus kept, direct swap under reduced motion. inset sets the minimum versions: Chrome 87, Firefox 66, Safari 14.1.
Without JavaScript, page A stays on screen and the button does nothing: provide a regular link to the next page. Without inset (Safari before 14.1), write top: 0; right: 0; bottom: 0; left: 0 on .transition-content and .transition-overlay.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="zt-stage">
<div class="transition-preview">
<div class="transition-content old-content">Page A</div>
<div class="transition-content new-content">Page B</div>
<div class="transition-overlay zoom-through-overlay"></div>
</div>
<button type="button" class="trigger-btn">Trigger Transition</button>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Disc color (CSS — .zoom-through-overlay { background }) |
#0a0a0f | Black gives the dive; a light color gives a dazzle instead, an exit toward the light. Stay opaque. |
Starting point (CSS — transform-origin on .zoom-through-overlay) |
center of the screen | transform-origin: 80% 30% starts the disc from the tapped spot (a door, a planet). Keep scale(3) or go up to 4 to cover the opposite corner. |
Maximum scale (CSS — scale(3) at 40% and 60%) |
3 times the screen size | With the rounding back to 0, scale(1) is enough to cover the screen from the center; 3 brings the black in sooner and leaves room for an off-center start. Larger speeds up the growth without changing anything else. |
Duration (CSS — animation: … 1.2s; JS — SWAP_AT, END_AT) |
1.2 s; swap at 600 ms, end at 1,200 ms | Change all three together, SWAP_AT at half. 1.6 s makes the dive more solemn, for the start of an exam or a tour. |
Content (HTML — .old-content, .new-content) |
"Page A" and "Page B" on two gradients | Any HTML. The central black suits a dark B content well: the eye moves on without glare. |
FAQ
border-radius goes from 50% to 0 while the scale rises. At the start, the box rounded at 50% is an ellipse (wider than tall, like the screen); at scale(3), its corners are square and it overflows everywhere. Without that change, the ellipse's curves would leave the screen visible longer in the corners.transform-origin, then call stage.querySelector('.trigger-btn').click(). The disc then starts from the tapped element; raise scale(3) to 4 if the element is near an edge.