Skip to content
animorio
IT
Back to the library

Photo focal point

Images, HoverGSAPMediumCompressed weight: Demo 9.1 KBGSAP 28 KBFreeDownload the zip

The focal point panel in the image library of an invented CMS, dark and premium like a Dribbble shot: over a real photo of dunes at sunset a reticle marks what matters in the picture. Dragged, it runs on a spring, the thirds appear and below it the three crops, square, 4:5 post and 3:1 banner, reframe themselves one after the other around the chosen point. Showing a crop, the photo darkens outside its window, which slides from one format to the next; Apply lights the three frames in turn.

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>
<!--
  "Photo focal point" 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 focal point with the crops that follow it</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>
  <main class="stage">
    <!-- the focal point panel of the media library of an invented CMS (Fieldnote). The photo, a real one: a
         panorama of dunes at sunset. Drag the reticle to choose what matters in the photo: the three crops under it
         (square, portrait, banner) reframe themselves around it, one after the other, each on its own spring -->
    <div class="panel" data-panel>
      <header class="panel__head">
        <div class="panel__file">
          <p class="panel__name">dune-crest.jpg</p>
          <p class="panel__meta">5472 × 3078 <span class="panel__sep" aria-hidden="true"></span> 6.1 MB</p>
        </div>
        <span class="panel__chip">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2.5v3M8 10.5v3M2.5 8h3M10.5 8h3"/><circle cx="8" cy="8" r="3.6"/></svg>
          Focal point
        </span>
      </header>

      <div class="view" data-view>
        <img class="view__img" data-photo src="dune-crest.webp" alt="A panorama of sand dunes at sunset, with a low hazy sun over the horizon" decoding="async">
        <span class="view__glow" data-glow aria-hidden="true"></span>
        <span class="view__thirds" data-thirds aria-hidden="true"></span>
        <span class="view__shade" data-shade aria-hidden="true"><span class="view__shade-tag" data-shadetag>1:1</span></span>
        <span class="view__edge" aria-hidden="true"></span>
        <span class="mark" data-mark role="slider" tabindex="0" aria-label="Focal point" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50" aria-valuetext="50% across, 45% down">
          <span class="mark__face" data-markface>
            <svg viewBox="0 0 40 40" aria-hidden="true">
              <circle class="mark__ring" cx="20" cy="20" r="11"/>
              <path class="mark__ticks" d="M20 3.5v6M20 30.5v6M3.5 20h6M30.5 20h6"/>
              <path class="mark__cross" d="M20 17.6v4.8M17.6 20h4.8"/>
            </svg>
          </span>
        </span>
      </div>

      <div class="crops">
        <figure class="crop" data-crop data-ratio="1" data-name="Square">
          <div class="crop__frame"><img class="crop__img" data-img src="dune-crest.webp" alt=""></div>
          <figcaption class="crop__cap"><span>Square</span><span class="crop__r">1:1</span></figcaption>
        </figure>
        <figure class="crop" data-crop data-ratio="0.8" data-name="Portrait">
          <div class="crop__frame"><img class="crop__img" data-img src="dune-crest.webp" alt=""></div>
          <figcaption class="crop__cap"><span>Post</span><span class="crop__r">4:5</span></figcaption>
        </figure>
        <figure class="crop crop--wide" data-crop data-ratio="3" data-name="Banner">
          <div class="crop__frame"><img class="crop__img" data-img src="dune-crest.webp" alt=""></div>
          <figcaption class="crop__cap"><span>Banner</span><span class="crop__r">3:1</span></figcaption>
        </figure>
      </div>

      <footer class="panel__foot">
        <p class="panel__pos">
          <span class="panel__axis">X</span><span class="panel__num" data-x>50</span><span class="panel__pc">%</span>
          <span class="panel__axis">Y</span><span class="panel__num" data-y>45</span><span class="panel__pc">%</span>
        </p>
        <button class="save" type="button" data-save>
          <span class="save__face" data-face>
            <svg class="save__icon" viewBox="0 0 16 16" aria-hidden="true">
              <path class="save__check" data-check pathLength="1" d="M3.4 8.4l3 3 6.2-6.6"/>
            </svg>
            <span class="save__words" data-words>Apply to crops</span>
          </span>
        </button>
      </footer>
    </div>
    <p class="sr" aria-live="polite" data-live></p>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.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.

35 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 “Photo focal point” 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 a near black page, with a soft warm light behind and a fine grain, a dark panel rises with round corners, a thread of light on its top edge and a layered shadow. At the top the file name, ‘dune-crest.jpg’, its size and weight, and on the right a ‘Focal point’ label with a small orange reticle. Below, the wide real photo of a panorama of dunes at sunset: a hazy pink and cream sky, a low pale sun over the horizon, a big near dune on the left with wind ripples and, far off, rows of lower dunes with tyre tracks, lost in the haze. On the photo sits the white reticle of the focal point. The reticle is picked up: it shrinks a little, fills with a disc of frosted glass and the lines of the thirds appear on the photo; then it runs onto the sun, passes the mark by a pixel and settles, while a soft light follows it. Under the photo the three crops, Square 1:1, Post 4:5 and Banner 3:1, reframe themselves around the sun one after the other, each on a softer spring than the one before, and lean in a little while they move, like a lens hunting. Then the crops are shown on the photo one at a time: outside the crop's window the photo sinks under a dark veil, the window slides on a spring from the square to the 4:5 to the banner and the matching frame below lights up in orange. The reticle then goes to the far dunes on the right, the crops follow it, the banner is shown, and the ‘Apply to crops’ button is pressed: it gives under the finger, springs back, the label becomes ‘Applied to 3 crops’ with a checkmark that draws itself and the three frames light up and hop slightly one after the other. At the bottom left the X and Y percentages of the point count as it moves. Then the reticle goes back to the middle and the loop starts again. With a mouse or a finger the reticle can be dragged anywhere on the photo, hovering a crop shows its window on the photo, and the reticle also moves with the arrow keys.

How it works

One photo in four places

The photo is a single file, dune-crest.webp, 1024 by 576 (16:9, the same shape as the view). In the view it is a full-frame image with object-fit: cover; in the three crops it is the same image, wide or tall enough to cover the frame and moved by hand with a transform. No canvas and no pixel read: the browser downloads it once and uses it four times, and the demo also works opened from the file.

A crop is a box and an image

Each crop is a frame with aspect-ratio holding the image just large enough to cover it (as tall as the frame if the format is narrower than the photo, as wide if it is wider). The offset puts the focal point in the middle and keeps it inside the edges: max(frame width minus image width, min(0, half the frame minus fx times the image width)).

Springs in a row

The reticle chases the point on a spring integrated by hand (stiffness 210, damping 19, three steps per frame); each crop chases the reticle on a softer spring than the one before, multiplied by FOLLOW, so they reframe in a cascade. While it moves, a crop leans in a little around its focal point, in proportion to its speed.

The window on the photo

The crop shown is a rectangle with a 1px white edge and a huge dark shadow all around it (a 200vmax box-shadow): outside darkens, inside stays lit. Its position and size have a spring of their own, so it slides from one format to the next passing the mark.

The loop and the hand

A looping GSAP timeline moves the point and calls hold, release, show and Apply. As soon as a hand touches the photo, a crop or the button, the timeline pauses and starts again after three quiet seconds, from where the hand left the reticle.

Values to change

NameFileDefaultWhat it changes
STIFFNESSscript.js210The spring carrying the reticle: higher is quicker.
DAMPINGscript.js19Lower lets the reticle pass the mark and come back.
FOLLOWscript.js0.62How much softer each crop is than the one before: 1 = all together.
LEANscript.js0.05How much a crop leans in while it moves.
VEILscript.js0.52How dark the photo gets outside the crop shown.
GLOWscript.js1The soft light at the focal point.
SPEEDscript.js12 = the loop on its own twice as fast, 0.5 = half.
LOOPscript.jstrueRepeats the loop.

Try them in the Playground

When to use it

For the media manager of a CMS, a listings site or an online shop, for the photo editor of a social app or a portfolio: wherever a photo is uploaded once and the site has to crop it well in many formats.

On phones

The same animation with adapted sizes: the panel is as wide as the box allows and also shrinks with the height, the crops stay in one row and the reticle is dragged with a finger (the photo does not scroll the page while it is held).

With reduced motion

No movement: the reticle fades out and back in at the new point, the crops are in place at once, the window on the photo and the button's label change with a fade.

Pitfalls

  • The crop has to stay inside the photo: without the two limits (zero and frame width minus image width) a point near the edge leaves an empty strip.
  • The lean while a crop moves must happen around the focal point and only upward (scale above 1): that way the image keeps covering the whole frame.
  • On phones the photo has touch-action: none, otherwise dragging the reticle scrolls the page.
  • The RATIO constant in the script has to be the photo's real shape (16:9): with a photo of another shape the crops get the image size wrong and leave empty strips or cut the focal point. If you change the photo, crop it to 16:9 or change RATIO.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 9.1 KB; the libraries: GSAP 28 KB.

Testing

Tested on 6 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