Skip to content
animorio
IT
Back to the library

Filter gallery

Images, TransitionsGSAP, CanvasMediumCompressed weight: Demo 7.6 KBGSAP 28 KBFreeDownload the zip

The work page of a made-up studio, in the style of product components: a row of pill filters and a mosaic of twelve projects. Changing the filter, the black pill slides under the chosen item, the projects that don’t belong shrink and fade, the ones that stay slide to their new place with short staggered springs, the new ones grow in, the grid changes height with a small bounce and the project count rolls.

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>
<!--
  "Filter 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 gallery that rearranges when you change the filter</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" data-stage>
    <!-- the work page of a made-up studio, Kettleby: a row of filter pills and a mosaic of twelve projects.
         Changing the filter, the projects that stay slide to their new place, the others shrink away or grow in -->
    <section class="work" data-work>
      <header class="top">
        <div class="top__head">
          <span class="top__brand">
            <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 4v16M5 12l9-8M5 12l10 8"/></svg>
            <span data-brand>Kettleby</span>
          </span>
          <h1 class="top__title">Selected work</h1>
        </div>
        <p class="count" aria-live="polite"><span class="count__num" data-count></span> <span data-count-word>projects</span></p>
      </header>

      <nav class="filters" data-filters aria-label="Filter projects">
        <span class="filters__pill" data-pill aria-hidden="true"></span>
        <button class="filter is-on" type="button" data-filter="all" aria-pressed="true"><span>All</span></button>
        <button class="filter" type="button" data-filter="brand" aria-pressed="false"><span>Brand</span></button>
        <button class="filter" type="button" data-filter="product" aria-pressed="false"><span>Product</span></button>
        <button class="filter" type="button" data-filter="motion" aria-pressed="false"><span>Motion</span></button>
      </nav>

      <div class="grid" data-grid></div>
    </section>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3l14 8-6 1.6L10 19z"/></svg>
  </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.

20 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 “Filter 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 a barely grey white sits the work page of Kettleby, a made-up studio: at the top the logo, the title Selected work and on the right the project count, below a row of filters inside a white pill with a thin border (All, Brand, Product, Motion), then a mosaic of twelve projects, one large two by two, one wide and the others square, with covers painted in the code: gradients, a sun, an object with its shadow, waves, stripes and circles, all with grain. Hovering a project, its card lifts three pixels with a bounce, the shadow grows, the image comes slightly closer and the project name rises from below with its year. Choosing a filter, the black pill slides under the item with a spring and the label gives a small jolt; the projects that don’t belong stay where they were, shrink and fade, the ones that stay leave their old spot and slide to the new one in turn, one pixel past and back, and the new ones grow in. Meanwhile the grid gets shorter or taller with the same bounce and the count rolls digit by digit. The drawn pointer goes from one filter to the next and rests on a few projects.

How it works

A mosaic that always fits

The grid has four columns and grid-auto-flow: dense, so every filter fills its gaps by itself. The large project spans two columns and two rows, the wide one two columns. The row height comes from misura(): the smaller of three quarters of a column and a quarter of the space left below the filters, so the whole mosaic always fits the window.

FLIP by hand

Before the change the rectangles of the visible projects and the grid height are read. The projects that leave become absolute where they are, so they don’t push the others; the new ones are switched on. Then everything is read again: every project that stays starts with x and y equal to the gap between old and new place and returns to zero with back.out, staggered by STAGGER.

Leaving, entering, changing height

Leaving projects go down to 0.86 and fade in 0.32 seconds, new ones grow from 0.82 with the same spring, and the grid goes from the old height to the new one with a fromTo on height. At the end the leaving projects are hidden again and lose their inline styles.

The pill and the count

The black pill is an element under the buttons: it moves with x and width to the chosen button with back.out. The project count is made of columns of digits, one per position, that rise by as many rows as the digit.

The painted covers

Every cover is a 640 by 480 canvas painted once: a gradient in the category’s three colours, a glow, a shape (sun, object, waves, stripes, circles or horizon) and grain from a fixed seed generator, then a JPEG dataURL as the card background.

Values to change

NameFileDefaultWhat it changes
STUDIOscript.js'Kettleby'The name of the made-up studio, at the top left.
MOVEscript.js0.75The seconds the projects that stay take to slide to their new place.
STAGGERscript.js0.035The stagger between one project and the next, in seconds.
BOUNCEscript.js1.25How far the spring goes past its place before settling.
GRAINscript.js16How much grain the painted covers have, from 0 to 40.
HOLDscript.js2.4The seconds the autopilot keeps a filter before changing it.

Try them in the Playground

When to use it

For the work page of a studio, a photographer or an agency, or for a shop catalogue: visitors pick a category and watch the mosaic put itself back in order, without losing track of where the projects went.

On phones

The same animation with adapted sizes: the title goes above the count, the grid keeps four columns and the row height is computed on the box height, so the whole mosaic fits. A tap on a filter selects it.

With reduced motion

No sliding: the grid fades out, changes and fades back in; the pill and the count jump straight to their place.

Pitfalls

  • Leaving projects must be taken out of the flow (position absolute at their spot) before measuring the new places, otherwise they still hold their cells and the measured places are wrong.
  • GSAP’s transform on the projects would cancel the hover one: the lift lives on the inner card, the FLIP on the container.
  • With grid-auto-flow: dense the visual order is not the source order: for the autopilot and the keyboard the DOM order is what counts.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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