Platform
VaultVault
  • Free15
  • Navigation19
  • Buttons9
  • Scroll55
  • Text27
  • Sliders & marquees19
  • Gallery & images67
  • Cursor24
  • Page transitions10
  • Loaders2
  • Backgrounds10
  • UI components33
ButtonsPart of ProButtons
IconsPart of ProIcons
  • Interface Essentials144
  • Social Icons69
  • Payment Badges41
SavedPart of ProSaved
Support
DocumentationDocumentation
MCP serverMCP server
SettingsSettings
VaultScrollFog Image Swap
Frame to Frame ImageBrowse all 182Cursor Follow Tooltip
  • Free15
  • Navigation19
  • Buttons9
  • Scroll55
  • Text27
  • Sliders & marquees19
  • Gallery & images67
  • Cursor24
  • Page transitions10
  • Loaders2
  • Backgrounds10
  • UI components33
  • Interface Essentials144
  • Social Icons69
  • Payment Badges41
Sign inSign in

Start free. The code for 15 components, no card needed.

Get 15 free

Fog Image Swap

This one is locked. Become a member to open the code for it and the rest of the Vault.

See plansTry the 15 free ones

What you'll need.

Install

  • gsap
  • ScrollTrigger
  • three

Setup

npm i gsapregisterPlugin(ScrollTrigger, three)

More like this

  • Pinned
  • Reveal
  • ScrollTrigger
  • Sticky
  • Canvas
  • WebGL

Features.

  • A pinned, full-screen scroll transition between two photos through a whiteout
  • A band of fog rolls up the screen: the first photo goes soft, then grey, then vanishes into off-white
  • The fog clears onto the second photo, which swaps in only while the frame is fully white
  • Three layers of fog (a billowing body, a thin veil and fine wisps) churn in place instead of sliding
  • Each title blurs and fades with the fog at its own height
  • The fog keeps churning gently while it's on screen, even when you stop scrolling
  • Without WebGL the photos and titles swap outright at halfway
  • Respects prefers-reduced-motion: no fog, one screen showing the second photo and its title

How to get it right.

Load GSAP, ScrollTrigger and three.js first

The script reads window.gsap, window.ScrollTrigger and window.THREE. Load all three before code.js. If three never arrives, the section still swaps the photos at halfway.

Give it room to scroll

The section is --fgs-length tall (300vh by default) with a sticky stage inside, and its full length drives the fog. Don't put it inside a parent with overflow: hidden, or the stage stops sticking.

Keep plate B first in the markup

Photo B sits under photo A as a plain <img>; both show until the shader has them. Keep the order from code.html.

Pick the fog colour for the photos

--fgs-fog sets the fog (read once at init). A warm off-white suits sunlit stone and sand; a cool grey suits snow and sea; a colour makes it read as smoke or dust. Titles sit on the photos, so keep --fgs-fg readable on both.

Shape the fog

data-au-warp sets how much the body billows, data-au-softness how soft the band's edges are, and data-au-mist how strong the thin veil around it is. data-au-drift sets the idle churn; 0 moves the fog only on scroll.

Labels are optional

Each photo ships with a title only. For a short line under it, add <p class="fgs_label"> after .fgs_title (label in React).

Variations.

  • Dust storm — the default: warm #e6e0d3, warp 0.6, softness 0.12
  • Sea fret — --fgs-fog: #ccc5b9 with data-au-mist="0.7" for a cooler, thicker veil
  • Smoke — --fgs-fog: #f68e66 for a coloured, smoky swap
  • Hard front — data-au-softness="0.04" and data-au-warp="0.2" for a crisp, flat wall of fog
  • Long storm — --fgs-length: 500vh so the whiteout takes longer

Where it fits.

  • Before / after — one place at two times, or a site before and after a build
  • Travel and editorial — a weather change between two chapters
  • Architecture — moving from the outside of a building to the inside
  • Product stories — one scene dissolving into the next

Frequently asked.

That's the fallback: three.js isn't loaded or WebGL isn't available.

That's reduced motion: the section shows the cleared end state.

Not in one section. Stack two sections, with the second starting on the first's last photo.

Yes. It listens to ScrollTrigger, so Lenis or any scroller that updates ScrollTrigger works.

Related components.

NewPro

Arc Collage Hero

Scroll

Pro

Rising Card on Scroll

Scroll

Pro

Outline Paint Reveal

Scroll