Bubble Morph
A colored bubble forms, holds for a beat, then swells into a rounded square until it fills the screen; the page changes underneath and the shape runs the same path backwards. Two clearly readable beats in 1.5 s, a scale computed to cover any screen, CSS + 1.8 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
Inside the .mph-screen, a .mph-layer centers a single shape with flexbox, .mph-shape: a 100 px disc with a green gradient, shrunk to scale(0) at rest. Clicking .mph-btn starts the mphMorph animation in four quarters of 375 ms: the bubble appears and reaches its 100 px, swells to its maximum size while its rounding goes from 50% to 10%, comes back to the bubble, then goes out. Only two properties move, transform: scale() and border-radius: nothing is laid out again.
The ease-in-out curve applies to each quarter separately, so the shape slows to a stop when it has its bubble size, at 375 ms and at 1,125 ms. That held beat is what gives the feeling of a drop forming before it bursts. Read on a 568 × 200 px screen: 51 px at 190 ms, 100 px at 375 ms, 639 px at 560 ms, 1,204 px at 750 ms; the shape's box overlaps the whole screen from about 550 ms.
The maximum size is not fixed. On each click the script measures the screen and writes into --mph-cover the scale that gives the shape twice the screen's diagonal (12.04 for the screen above). That margin means it still covers it if you start it from a corner, or shrink it to a 14 px dot. The pages swap at 750 ms, at the peak, through the .mph-is-b class; at 1.5 s the button is handed back. A click in between is ignored, and every .mph-stage on the page runs independently of the others.
Accessibility
- Reduced motion: a shape growing until it swallows the screen is among the movements to avoid for sensitive people. If
prefers-reduced-motionis on at click time, the bubble does not form; the two pages cross in 150 ms of opacity (shape size kept at 0, page B set 60 ms after the click). - Color area: the screen is fully painted in the bubble's color for about 0.4 s, once per click, with no flicker. On a very large screen, prefer a tint close to the pages' over a bright red or white.
- Keyboard: the control is a
<button>(Enter, Space). It keeps focus during the transition, when it only carriesaria-disabled="true". 2 px outline on keyboard focus, which fades in over 0.3 s because the button has a transition on all its properties. - Screen readers: the masked page is
visibility: hiddenand the shape's layer isaria-hidden, but the page change is silent. For a confirmation (sign-up, payment), put the message in arole="status"region.
Browser compatibility
CSS (@keyframes on scale() and border-radius, the --mph-cover variable read inside the keyframe, flexbox, inset) + 1.8 KB of JavaScript (Math.hypot, getBoundingClientRect, matchMedia). Everything is 2D: the three engines tested, Chromium 149, Firefox 151 and WebKit 26.5, give the same sizes at the same instants (100 px at 375 ms, 1,204 px at 750 ms) and the same end state. The floor comes from inset: Chrome 87, Firefox 66, Safari 14.1.
If the script does not run, nothing moves: page A stays on screen. If the --mph-cover variable is missing, the keyframe falls back to a scale of 20, enough for a screen whose diagonal stays under 1,000 px with the 100 px bubble.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="mph-stage">
<div class="mph-screen">
<div class="mph-page mph-page-a">…</div>
<div class="mph-page mph-page-b">…</div>
<div class="mph-layer" aria-hidden="true">
<div class="mph-shape"></div>
</div>
</div>
<button type="button" class="mph-btn">…</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 |
|---|---|---|
Bubble color (CSS — .mph-shape { background }) |
#047857 → #0e7490 gradient |
The same shape is used both ways. Take the color of the triggering button if the bubble should seem to come out of it, or a status color (red, green) for a tile. |
Bubble size (CSS — .mph-shape { width; height }) |
100 px | It is the size of the held beat. The script reads the shape's real width to compute the scale: from 14 px to 100 px, nothing else to change. |
Starting point (CSS — align-items, justify-content and padding on .mph-layer) |
center of the screen | flex-end on both axes starts it from the bottom right corner, flex-start from the top left; the padding sets the gap to the edge. The screen stays covered at the peak. |
Rounding at the peak (CSS — border-radius: 10% at 50% of @keyframes mphMorph) |
10% | 0 gives a sharp rectangle, 50% keeps a circle from start to finish: the morph is gone, only a growth remains. |
Duration (CSS — animation: mphMorph 1.5s; JS — SWAP_AT, END_AT) |
1.5 s; swap at 750 ms, end at 1,500 ms | Keep SWAP_AT at half the duration and END_AT equal to it. At 0.9 s the effect becomes a mere pulse; past 2 s the wait is felt. |
FAQ
scale(0) to scale(3)) and holds it for two tenths of a second: a centered dive into black, in 1.2 s. Bubble Morph works in two beats with a small colored shape: it forms, stops at its bubble size, then swells by a scale computed from the screen. So you can start it from a button or a dot, which Zoom Through's full-frame layer does not allow.scale(1), and ease-in-out restarts from zero at every keyframe. For a swell in a single stroke, delete the 25%, 75% block from @keyframes mphMorph: the shape will go from 0 to its maximum size with no pause, and the result will come close to Zoom Through.--mph-cover scale is measured at each click, not at load: after a phone rotation or a window resize, the next transition covers the new screen. Only a transition already running keeps the scale computed when it started, for 1.5 s at most.