Skip to content
animorio
IT
Back to the library

Pointer-side gallery

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

A hover effect for an image gallery, in the minimal style: four square prints in stone tones. When the pointer comes into a photo, its colour take slides in from the very side the pointer came from, on a short spring that goes one pixel past and settles, and pushes the plain print a little ahead of it; when the pointer leaves, the take slides out through the side it leaves by and the plain print follows it back. Crossing the grid, the photos take their colour one after another in the direction of the gesture.

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>
<!--
  "Pointer-side gallery" 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 prints that slide in from the pointer's side</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="scena" data-stage>
    <div class="palco">
      <!-- four square prints; the script draws them and slides the colour take in from the side the pointer comes from -->
      <div class="griglia" data-grid aria-label="Fenwick Prints, four colour studies"></div>
      <!-- the small caption under the prints -->
      <p class="didascalia">
        <span>Fenwick Prints</span>
        <span data-caption>Four colour studies</span>
      </p>
    </div>
  </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.

21 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 “Pointer-side gallery” 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 empty warm white, four square photos in two rows, slightly apart, rise a few pixels one after the other: prints in stone tones made of simple shapes and soft gradients (a sun on the horizon, an arch, three bands like a tide, a quarter circle with a small square). Below, small and grey, the caption of an invented print shop. When the pointer comes into a photo, its colour take, all in shades of orange, slides in from the exact side the pointer came from: from the left if you come from the left, from the top if you come from the top. It runs on a short spring, lands one pixel past and settles, and on its way pushes the plain print a little ahead, a quarter of the way, underneath it. In the top left corner the colour take carries its title with a small arrow pointing the way it came in; the letters are narrow while it travels and widen once it stops. When the pointer leaves, the colour take slides out through the side it leaves by and the plain print follows it back from behind. Moving from one photo to the next, the first slides out towards the second and the second comes in from that side: the colour crosses the grid in the direction of the gesture. Pressing a photo sinks it a little and letting go brings it back up on a spring. If nobody touches, an invisible pointer crosses the four photos, once from the left and once from the top.

How it works

The side you come from

For every photo the script compares the pointer’s previous point with the centre of the cell, divided by half its width and half its height: the longer axis wins and its sign gives the side. On the way out the same sum with the current point gives the side it leaves by.

A spring in shares of a photo

The colour take keeps its position in shares of the photo: 0 is in place, 1 is one photo away. A spring (stiffness 360, damping 33) chases it in four small steps per frame; every draw multiplies the share by the cell width, so it holds up on resize too.

The plain print that follows

While the colour take comes in, the plain print moves a quarter ahead in the same direction. If the take leaves while it covers everything, the plain print hides on the side opposite the way out, so it follows the take into place instead of going back the way it came.

The title that widens

The arrow on the title is turned only once, when the take comes in from outside; the width (Mona Sans wdth) and the weight follow the square of how much of the photo is covered, so they widen mostly at the end, while it settles.

One pointer only

The mouse, the finger and the invisible pointer all go through the same function, which finds the photo under the point. The invisible pointer is a point in shares of the grid that a GSAP timeline walks around; the real mouse stops it and it comes back a few seconds after the mouse leaves the grid.

Values to change

NameFileDefaultWhat it changes
STIFFNESSscript.js360How hard the spring pulls the colour take into place.
DAMPINGscript.js33How quickly it calms down: lower bounces more, 33 is one pixel past and back.
PUSHscript.js0.24How far the plain print is pushed ahead, as a share of the photo.
PRESSscript.js0.965How much a pressed photo sinks (1 = not at all).
SPEEDscript.js1The speed of the invisible pointer: 2 = twice as fast, 0.5 = half.
AUTOPLAYscript.jstrueWhen nobody touches, an invisible pointer crosses the photos.
IDLEscript.js2.6Seconds without the real pointer before the invisible one comes back.

Try them in the Playground

When to use it

For the gallery of a portfolio, a design studio or a print shop, for product previews in a shop with a colour version or a second photo, for the rooms of a hotel: whenever a photo has another face to show on hover.

On phones

The same animation with adapted sizes: the four photos are as big as the box allows, in width and height. With a finger, the photo you tap takes its colour from the side nearest the finger, and dragging moves the colour from photo to photo; tapping outside the grid turns it plain again.

With reduced motion

No sliding: the colour take appears and disappears with a fade, and the photos arrive with a fade only.

Pitfalls

  • The entry side has to be worked out from the previous point, the one still outside the photo: with a fast mouse the current point is already inside and gives the wrong side.
  • The plain print never jumps while it can be seen: it moves to the other side only when the colour take covers all of it.
  • Measure the cell, move the photo: pressing shrinks the photo and, measuring that, a pointer on the edge would leave and enter again and again.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 31 October 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