Skip to content
animorio
IT
Back to the library

Focus pull photo

Images, ScrollGSAP, CSS onlyMediumCompressed weight: Demo 7.1 KBGSAP + ScrollTrigger 45 KBLenis 5.3 KBFreeDownload the zip

Scroll inside the preview

A minimal image animation on scroll: a single real photo, blue ridges over still water at sunset, arrives soft and slightly too big, like a lens that is not set yet. Scrolling down turns the focus: the photo breathes back to its size and sharpens plane by plane, the water in front first, then the near hill and the ridges, the sky last. Underneath, a thin distance scale slides under an orange index to the right 5 metres; there it goes one pixel past and settles, the four corner marks close in and take the accent, and only then does the caption rise.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Focus pull photo" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The photo that comes into focus on scroll</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- one photograph and a long scroll: the stage stays still while the page scrolls under it, and the scroll turns
       the focus of the lens. The same real photo is laid four times, each copy cut to one band (the sky, the far
       ridges, the near hill, the water in front); every band has its own distance, so they sharpen one after the
       other, the nearest first -->
  <main class="corsa" data-run>
    <div class="palco" data-stage>
      <figure class="foto">
        <div class="cornice" data-frame>
          <div class="lente" data-lens role="img" aria-label="Layers of blue ridges over still water under a golden evening sky">
            <img class="piano" data-plane="sky" src="ridge.webp" width="960" height="720" alt="" decoding="async">
            <img class="piano" data-plane="far" src="ridge.webp" width="960" height="720" alt="" decoding="async">
            <img class="piano" data-plane="mid" src="ridge.webp" width="960" height="720" alt="" decoding="async">
            <img class="piano" data-plane="near" src="ridge.webp" width="960" height="720" alt="" decoding="async">
          </div>
          <!-- the four thin corner marks of the focus frame: they close in a pixel and take the accent when it is sharp -->
          <span class="angolo angolo--a" data-corner></span>
          <span class="angolo angolo--b" data-corner></span>
          <span class="angolo angolo--c" data-corner></span>
          <span class="angolo angolo--d" data-corner></span>
        </div>

        <!-- the distance scale of the lens: it slides under a fixed index until the right number -->
        <div class="scala" data-scale aria-hidden="true">
          <div class="scala__nastro" data-tape></div>
          <span class="scala__indice" data-index></span>
        </div>

        <figcaption class="dida" data-caption>
          <span class="dida__riga"><span class="dida__testo" data-cap-line>Third ridge, the last light</span></span>
          <span class="dida__riga"><span class="dida__meta" data-cap-line data-cap-meta>5 m, f/8, 1/250 s</span></span>
        </figcaption>
      </figure>
      <p class="nota" data-hint>Scroll to focus</p>
    </div>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/lenis@1.3.26/dist/lenis.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

17 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Focus pull photo” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On warm white, in the middle, there is one photo: a real photo of a layered landscape: a golden sky with clouds lit by the sunset, a row of blue ridges, a darker wooded hill nearer, and at the bottom still water with a rock and a small beacon. It arrives all soft and a little bigger than its frame, with four thin viewfinder corner marks coming in from the sides. Underneath is a distance scale like the one on a lens barrel, numbers and ticks from 0.5 metres to infinity, resting under an orange index on 0.5. As you scroll the page holds still and the focus turns: the scale slides left, the numbers passing under the index gain weight, the photo breathes back to its size and sharpens one plane at a time, as in a real lens: first the water in front, then the near hill, then the far ridges and last the sky with its clouds. When the index reaches 5 the scale goes one pixel past and comes back on a small spring, the index gives a knock, the 5 turns black and bold, the four corners close in on the photo and turn orange. Only then does the caption rise, the title and under it the distance, aperture and shutter speed. Scrolling back up the photo goes soft again and the caption drops. Tapping the photo once it is sharp makes the lens hunt again, like a half press of the shutter: it blurs for a moment and finds focus with the same settle; with the pointer over it the corners lean in a pixel and a half.

How it works

Four bands, four distances

The real photo is laid four times on top of itself, and each copy is cut to its band by a CSS mask: the whole sky at the back, the far ridges, the near hill, the water in front. Each band has its own distance, and its blur comes from how far it is from the focus (in 1/d, as in a real lens) minus a depth of field that keeps them all sharp once focused: so they sharpen one after the other with no hand-made timing.

A log scale

On a lens barrel near numbers are wide apart and far ones close: here each number sits at the logarithm of its distance, and the focus travels from start to target in log too, so the tape slides evenly under the index.

A long section, a still stage

The section is over three screens tall and the stage inside is sticky at 100lvh; a single ScrollTrigger gives the progress and Lenis softens it. The settling knock fires when you reach the end and resets below 98.5%.

Bigger than the frame

The four copies of the photo are 12% bigger than the frame and the whole sky sits behind them all: with CSS blur the edges never fade into the background.

Values to change

NameFileDefaultWhat it changes
TARGETscript.js5The distance the photo is sharp at, in metres: the scale stops there.
STARTscript.js0.5The distance the lens starts from.
BLURscript.js0.03How soft it starts, compared with its width.
START_SCALEscript.js1.06How much bigger it starts.
FOCUS_ENDscript.js0.78How far down the page the focus is done.
STAGGERscript.jstrueThe planes sharpen one after the other, the nearest first.
OVERSHOOTscript.js2How many pixels the scale goes past before settling.
CAPTIONscript.jsThird ridge, the last lightThe caption that rises once it is sharp.
SMOOTHscript.js0.09How soft the scroll is.

Try them in the Playground

When to use it

For the opening photo of a photography portfolio, a long-form article or a travel page: a single picture that asks you to scroll to see it properly.

On phones

The same animation with adapted sizes: the photo is as large as the box allows, in width and height, and a tap makes the lens hunt again.

With reduced motion

The photo appears already sharp with the scale on 5, orange corners and the caption, in a fade; scrolling moves nothing.

Pitfalls

  • Scale the planes, not the frame that clips them: scaling the frame pushes the photo past the viewfinder corners.
  • With CSS blur an image edge fades into the background: the planes must be bigger than the frame.
  • The bands of the same photo all share the same size and position, with object-fit: cover and a frame in the photo’s own proportion: if one band moves by a pixel, the seam shows once it is sharp.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Lenis 1.3.26, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 7.1 KB; the libraries: GSAP + ScrollTrigger 45 KB, Lenis 5.3 KB.

Testing

Tested on 8 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations