TransitionsPremium

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.

CSSScaleZoom

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

Entering the MRI bore — an imaging center's patient information screen — Zoom Through example 1

① Entering the MRI bore — an imaging center's patient information screen

WhenThe technologist starts the exam: the instructions "stay still, the exam lasts 20 min" give way to the first sequence's countdown.
WhyThe dark disc growing from the center echoes entering the machine's bore: the patient understands the exam is starting, with no flash or bright color.
Settings512 × 258 px screen with 16 px corners, instructions on a light sea-green background, countdown on deep teal; original dark disc; progress ring in conic-gradient.
Entering the painted cave — a prehistory museum's virtual tour kiosk — Zoom Through example 2

② Entering the painted cave — a prehistory museum's virtual tour kiosk

WhenThe visitor taps "Enter": the map of the cave and its painted halls gives way to the first hall, plunged in darkness and lit by a lamp.
WhyThe screen is swallowed by its center like the mouth of a tunnel; animated in transform only, the change stays smooth on a low-end kiosk.
Settings512 × 276 px screen; map drawn in SVG on beige; hall lit by an ochre radial gradient, animal painted in SVG; big rounded "Enter" button.
Next scene of an interactive gamebook for teens — Zoom Through example 3

③ Next scene of an interactive gamebook for teens

WhenThe reader chooses "go into the cave": the end of chapter 7 gives way to the scene inside the cave.
WhyThe dive toward the center says "we're going in"; the disc's black makes the cut before the next scene.
Settings420 × 284 px book page, 14 px serif text on cream paper; original dark disc; the reader's choice as a full-width button under the page.

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.

Chrome 87+✓ Full
Firefox 66+✓ Full
Safari 14.1+✓ Full
Edge 87+✓ Full
Mobile iOS 14.5+✓ Full (on tap)
Android Chrome 87+✓ Full (on tap)

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):

index.html — structure
<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 / propertyDefaultEffect
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

Zoom Transition enlarges the view itself to move to a detailed state: the content grows, you "enter" the element. Zoom Through leaves the content alone: a dark disc grows over it, covers everything, the swap happens in the dark, and the disc withdraws. Zoom Transition to go from a thumbnail to its detail; Zoom Through for a change of place or scene, with a clean cut.
Because 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.
On click on the element, compute its position in the screen as percentages and write it into the layer's 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.