Scroll Image Mask — Free GSAP ScrollTrigger Clip-Path Reveal

Scroll Image Mask · Scroll · Plain HTML, CSS & JS · Live preview

Share & Support

What's included

Features

clip-path aperture
inset opens the frame edge by edge.
Pinned + scrubbed
Opening follows the scrollbar.
Counter-zoom
Media eases from 1.3 to 1 as it opens.
Timed caption
Text rises in after the open begins.
Steady media
Clip reveals without moving the image.
No reflow
clip-path composites, box stays fixed.
Reversible
Scrolling up closes the aperture.
Asset-free demo
Gradient stands in for a photo.

About this UI Snippet

Scroll Image Mask — Open an Image From a Slit to Fullscreen

Screenshot of the Scroll Image Mask snippet rendered live

The scroll image mask is the cinematic reveal where an image starts as a thin centered slot and expands to fill the frame as you scroll, while the picture inside subtly un-zooms — the dramatic media reveal from editorial and product launch pages. This snippet builds it with GSAP and ScrollTrigger (from a CDN) using an animated CSS clip-path.

clip-path inset as the mask

The frame's reveal is driven by clip-path: inset(...), which crops the element by a percentage from each edge. At rest it's inset(42% 38%) — cropped heavily top/bottom and left/right, leaving only a small central window. Animating the inset toward inset(0%) un-crops it edge by edge until the whole frame shows. Because clip-path clips rather than resizes, the media behind stays put while the visible window grows, which is exactly the "opening aperture" feel.

A scrubbed, pinned timeline

The stage pins (pin: true) and a scrubbed timeline runs for end: '+=140%', so the aperture opens in direct response to scrolling. Three tweens share position 0-ish: the clip-path opens, the media scales from 1.3 down to 1, and the caption rises in slightly later (at 0.3 on the timeline). ease: 'none' keeps the opening linear so it tracks the scrollbar, and the whole thing reverses on scroll-up.

The counter-zoom

The media starts scaled to 1.3 and eases to 1 as the mask opens. This counter-zoom is a subtle but important touch: as the window expands, the image gently pulls back, so you feel like you're seeing more of the scene rather than the same crop stretched. It mirrors the language of a camera revealing a wider shot.

Why clip-path over width/height

You could animate the frame's width and height, but that reflows layout and resizes the media with it, breaking the aperture illusion. clip-path is a GPU-composited paint operation — it changes only what's visible, not the box, so the image inside holds steady while the mask opens, and there's no layout thrash. will-change: clip-path hints the compositor.

Asset-free demo

The "photo" is layered CSS gradients with a darkening overlay so the caption stays legible. Swap .im-media's background for a real background-image and the reveal is identical, since the timeline only touches clip-path, transform, and opacity.

Customizing it

Change the starting inset for a different slit shape (a horizontal letterbox, a vertical slot), the open distance via end, the counter-zoom amount, or the caption timing. Pair it with a scroll split panels reveal, a scroll zoom hero, or a scroll curtain reveal.

Step by step

How to Use

  1. 1
    Add the GSAP CDNsInclude gsap and ScrollTrigger from the CDN panel.
  2. 2
    Paste HTML, CSS, and JSA small image slit sits in a pinned stage.
  3. 3
    Scroll downThe slit opens to a fullscreen frame.
  4. 4
    Watch the un-zoomThe image pulls back as the window grows.
  5. 5
    Scroll back upThe aperture closes — motion is scrubbed.
  6. 6
    Use a real imageSet background-image on the media layer.

Real-world uses

Common Use Cases

Media reveals
Pair with a scroll split panels open.
Hero intros
Lead into a scroll zoom hero.
Editorial
Frame an article's parallax hero.
Launches
Unveil with a scroll curtain reveal.
Galleries
Open into a scroll gallery pin.
Stories
Punctuate a scroll pin story.

Got questions?

Frequently Asked Questions

The frame uses clip-path: inset(), which crops it by a percentage from each edge. At rest it is inset(42% 38%), leaving a small central window, and the timeline animates the inset toward inset(0%) to un-crop it edge by edge. Because clip-path clips rather than resizes, the media stays put while the visible window grows.

The media starts at scale 1.3 and eases to 1 over the same scroll, a counter-zoom. As the aperture expands, the image gently pulls back so you feel like you are seeing more of the scene rather than the same crop stretched — it mirrors a camera revealing a wider shot, which makes the reveal cinematic.

Animating width and height reflows layout and resizes the media with the box, breaking the aperture illusion and causing layout thrash. clip-path is a GPU-composited paint operation that changes only what is visible, so the image holds steady while the mask opens. will-change: clip-path hints the compositor for smoothness.

The stage pins and the timeline is scrubbed over end: +=140%, so the clip-path open, the counter-zoom, and the caption rise all advance with the scrollbar and reverse on scroll-up. ease: none keeps the opening linear so it tracks scroll position exactly rather than playing on its own clock.

In a mount effect, register ScrollTrigger and build the pinned, scrubbed timeline scoped to refs for the stage, frame, media, and caption. Return a cleanup that reverts the GSAP context so the pin is removed on unmount. Swap the media background for an image; the clip-path CSS and timeline port unchanged. Note older Safari needs -webkit-clip-path.