webdevpuneet.com

Scroll Safe Dial Unlock: GSAP Vault Door Open Effect

Scroll Safe Dial Unlock: GSAP Vault Door Open Effect · Scroll · Plain HTML, CSS & JS · Live preview

Copy & paste

Source Code

<section class="sf-stage" id="sfStage">
  <p class="sf-kicker">Keystone Vault</p>
  <h1 class="sf-title">Scroll to crack the code</h1>
  <div class="sf-vault">
    <div class="sf-inside" id="sfInside">
      <h2>Inside the vault</h2>
      <ul>
        <li>Zero-knowledge encryption</li>
        <li>Hardware key backup</li>
        <li>Full audit trail</li>
      </ul>
    </div>
    <div class="sf-door" id="sfDoor">
      <span class="sf-bolt" id="sfB1"></span><span class="sf-bolt" id="sfB2"></span><span class="sf-bolt" id="sfB3"></span>
      <div class="sf-dial" id="sfDial" aria-hidden="true"><i class="sf-notch"></i><span class="sf-knob"></span></div>
      <div class="sf-handle" aria-hidden="true"></div>
    </div>
  </div>
  <div class="sf-panel">
    <span class="sf-led" id="sfL1"></span><span class="sf-led" id="sfL2"></span><span class="sf-led" id="sfL3"></span>
    <output class="sf-read" id="sfRead" aria-live="off">00</output>
  </div>
</section>
<section class="sf-after"><p>The vault is open. Keep scrolling.</p></section>

Extend with AI

Take This Snippet Further With AI

Paste this snippet into an AI coding assistant and ask it to explain how one scrubbed timeline sequences dial turns, LEDs, bolts and a 3D door, and how the dial's angle is converted into the number shown. Follow-ups worth trying: a second dial for a longer code, a click sound tied to each number, or a version where the final content is a pricing card. Ask it to keep reduced-motion support.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a "scroll safe dial unlock" in plain HTML, CSS and JavaScript using GSAP with ScrollTrigger (from a CDN).

Requirements:
- A pinned full-viewport stage with a kicker, a title, a square steel vault, and a small panel under it containing three LEDs and a two-digit number readout.
- Inside the vault frame, an interior panel (heading plus three checklist items) starts dimmed and slightly scaled down. A door sits over it with transform-origin left center inside a parent with perspective. The door holds a round combination dial (tick marks drawn with repeating-conic-gradient, a notch at the top, a knob), a handle and three bolts on its right edge.
- One GSAP timeline with a pinned ScrollTrigger (pin: true, scrub about 0.4, end: '+=2400'): the dial turns clockwise to 24, then counter-clockwise to 07, then clockwise to 61 (3.6 degrees per number, using an object tween and gsap.set for rotation). After each turn an LED switches from dark red to glowing green. Then bolts retract, the door rotates on Y to about -112 degrees, and the interior brightens and scales to 1.
- Update the readout from the current dial angle on every tween update.
- Scrolling back up must reverse everything.
- If prefers-reduced-motion is set, set the timeline to its end and skip the pin.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

What's included

Features

Three-number combination
Dial turns clockwise, counter-clockwise, then clockwise with an LED per stage.
Live number readout
The display shows the number currently at the top of the dial.
Retracting bolts
Three bolts slide into the door once the code is complete.
3D hinged door
perspective plus rotationY from the left edge swings the door open.
Pure CSS dial marks
A repeating-conic-gradient draws the tick marks without images.
Pinned and reversible
Scroll back up and the door closes, the dial reverses, LEDs reset.
Editable code
One array holds the combination; change three numbers and it still works.
Reduced-motion safe
With reduced motion the vault renders already open and no pin is used.

About this UI Snippet

Scroll Safe Dial Unlock: Crack a Combination to Open the Vault

Screenshot of the Scroll Safe Dial Unlock: GSAP Vault Door Open Effect snippet rendered live

Most reveal effects fade or slide. This one makes the visitor earn it. A steel vault door fills a pinned stage, and scrolling turns the combination dial: clockwise to 24, counter-clockwise to 07, clockwise to 61. A green LED lights after each correct number, the bolts slide back, and the door swings open on a 3D hinge to show what is inside.

One timeline, five stages

The sequence lives on a single GSAP timeline mapped to a pinned ScrollTrigger (end: '+=2400', scrub: 0.4). The first 30% is the three dial turns, 30-40% retracts the bolts, 40-80% swings the door, and the contents settle in last. Because it is scrubbed, scrolling back up spins the dial the other way and locks the door again.

A dial that really is a number

The dial is one rotation value in a small object. A show() function applies it with gsap.set(dial, { rotation }) and works out which of 100 numbers sits at the top (3.6 degrees per number), writing it to the readout. The numbers on screen therefore match the position of the marks.

Alternating directions

Each turn adds a full revolution, and the middle one targets a negative angle so the dial runs backwards. power2.inOut easing on each segment gives it a stop-and-go feel, like someone feeling for the click.

3D door on a hinge

The vault gets perspective: 1100px, and the door uses transform-origin: left center with rotationY: -112. The interior panel behind it starts dimmed and slightly scaled down and brightens as the door clears.

Making it your own

Change the turns array to set your own combination, restyle the contents, or lengthen the pin for a slower crack. With prefers-reduced-motion, the timeline jumps to its end and the vault starts open. For a related locked-content idea, see the PIN pad snippet, or follow this with a scroll portal gate.

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 closed vault with a dial, three LEDs and a number readout renders.
  3. 3
    Set your combinationEdit the turns array: one entry per number, alternating direction by using positive and negative angles.
  4. 4
    Put your content in .sf-insideThe headline and list are what the door reveals.
  5. 5
    Scroll downThe dial turns, LEDs light, bolts retract and the door opens.
  6. 6
    Adjust the lengthChange end: '+=2400' to make the safe harder or quicker to crack.

Real-world uses

Common Use Cases

Security and fintech product pages
Introduce encryption, custody or backup features by opening a vault, so the idea of "locked and safe" is shown before it is explained.
Secret feature or early-access reveals
Hide an announcement behind the dial and let scrolling unlock it. It suits a waitlist page, something like a scroll product launch story.
Escape-room and game marketing
Match a puzzle brand by making the landing page itself a lock that opens when the visitor reaches the end of the code.
Treasure, vault or loyalty rewards
Reveal a reward tier or coupon code inside the vault after the unlock, with a call-to-action button as the last item.

Got questions?

Frequently Asked Questions

The dial's rotation lives in a small object. A show() function applies it with gsap.set and converts it to a number: the angle modulo 360, divided by 3.6, rounded and wrapped at 100. That value is written to the readout on every update.

Edit the turns array. Each entry is an absolute angle: number times 3.6, plus or minus a full 360 for extra revolutions. Use a positive angle for clockwise and a negative one for counter-clockwise movement.

The door has transform-origin set to left center, so rotationY pivots around its left edge like a real hinge. The parent's perspective value controls how strong the 3D foreshortening looks.

Yes. The vault is sized with min() from viewport width and height, so it fits portrait phones. Scroll distance is the same on every device, so the unlock takes the same amount of scrolling everywhere.