Skip to content
animorio
IT
Back to the library

Rooms mosaic

Images, HoverGSAP, Canvas, CSS onlyMediumCompressed weight: Demo 8.1 KBGSAP 28 KBFreeDownload the zip

The rooms of a small made-up hotel in a mosaic of real photos, in the clean style of product interfaces: hover a photo and its column and row widen on a spring while the others make room without jumping, the picture follows the pointer and the caption with the price rises; click it and the room fills the whole mosaic with its details, and the cross closes it again.

The code

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

<!doctype html>
<!--
  "Rooms mosaic" 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>Wrenlow House, the rooms</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>
  <!-- the rooms of a small made-up hotel, Wrenlow House, in a mosaic of real photos. Hover a photo and
       its column and row widen on a spring while the others make room without jumping; the picture inside drifts with
       the pointer and its caption rises. Click it and it fills the whole mosaic with its details; the cross closes it -->
  <main class="stage" data-stage>
    <div class="wrap" data-wrap>
      <header class="head">
        <div class="brand">
          <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 20V9.5L12 4l8 5.5V20"/><path d="M9.5 20v-5.5h5V20"/></svg>
          <span data-hotel>Wrenlow House</span>
        </div>
        <p class="head__note" data-note>Five rooms by the sea</p>
      </header>

      <div class="mosaic" data-mosaic role="list" aria-label="Rooms"></div>
    </div>

    <svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer><path d="M5 3.5 18.5 12 12.4 13.6 9.4 19.6z"/></svg>
  </main>

  <template data-cell>
    <div class="cell" role="listitem">
      <button class="cell__hit" type="button" data-hit></button>
      <div class="cell__photo" data-photo><canvas data-canvas></canvas></div>
      <div class="cell__shade" aria-hidden="true"></div>
      <div class="cap" data-cap>
        <span class="cap__name" data-name></span>
        <span class="cap__price" data-price></span>
      </div>
      <div class="more" aria-hidden="true" data-more>
        <svg viewBox="0 0 24 24"><path d="M7 17 17 7M9 7h8v8"/></svg>
      </div>
      <div class="detail" data-detail>
        <div class="detail__top">
          <div>
            <p class="detail__kind" data-kind></p>
            <h2 class="detail__name" data-dname></h2>
          </div>
          <p class="detail__price"><strong data-dprice></strong><span>/ night</span></p>
        </div>
        <p class="detail__meta" data-meta></p>
        <div class="detail__foot">
          <span class="detail__free">Free cancellation</span>
          <span class="detail__book">Book this room</span>
        </div>
      </div>
      <button class="close" type="button" aria-label="Close" data-close>
        <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17"/></svg>
      </button>
    </div>
  </template>

  <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.

14 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 “Rooms mosaic” 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 warm white background sits Wrenlow House, a small made-up hotel, with five photos in a mosaic: the room with shutters and a door onto the beach, the stone bathroom with its tub, the sea terrace at dusk, the breakfast room and the pool among the trees. They are real photos, with a veil of grain. Hover a photo and its column and row widen on a spring that goes slightly past and comes back, while the others narrow without jumping: the photo is redrawn around its subject, never stretched. The photo follows the pointer by a few pixels, the veil at the bottom darkens, the price per night rises under the name and a white circle with an arrow appears in the top corner. Click it and the room widens to fill the whole mosaic, the others fade, and a white card rises from the bottom with the kind, the name, the price, two lines about the room, free cancellation and Book this room; the cross spins in and closes it again. A drawn pointer passes over the photos, opens the terrace and closes it.

How it works

A grid moved by weights

The mosaic is not a CSS grid: each cell says which columns and rows it spans, and the script computes the position and size of every cell from the weights of the columns and rows, on every frame. Widening a photo means raising the weight of its column to 2.1 and of its row to 1.7: the others narrow by themselves, always touching, with no jumps.

The spring on the weights

GSAP animates the two lists of weights, index by index, with back.out: the chosen cell goes slightly past and comes back, and every update redraws the mosaic. The corners follow the shape: the smaller the cell, the tighter the radius.

The photo never stretches

Each photo is a real photo drawn into a canvas as large as the whole mosaic, plus a margin for the drift. Whenever its cell changes size the photo is redrawn to cover it, around a focus point chosen for each room (the tub, the bed, the table): so a small cell still shows the subject, the open room shows the whole photo, and the picture can follow the pointer without showing its edges.

Two mosaics

In a wide box the mosaic has three columns and two rows, with the tall room on the left; in a tall box, like on a phone, it has two columns and three rows, with the wide room on top. On resize the mosaic is chosen again, measured and the photos redrawn.

Values to change

NameFileDefaultWhat it changes
HOTELscript.jsWrenlow HouseThe made-up hotel’s name, written at the top.
GROWscript.js2.1How much the chosen photo’s column widens compared with the others.
GROW_ROWscript.js1.7How much the chosen photo’s row grows.
SPRINGscript.js0.8The seconds of the spring that reshapes the mosaic.
PARALLAXscript.js16How many pixels the photo moves with the pointer: 0 no parallax.
ACCENTscript.js#c8553dThe accent colour.
HOLDscript.js2.4The seconds the open room stays full size before the drawn pointer closes it.

Try them in the Playground

When to use it

For the rooms page of a hotel, a B&B or a holiday home, or for a portfolio gallery: the mosaic shows everything at once and lets you look closely at one photo at a time without leaving the page.

On phones

The same mosaic, turned for the tall screen: two columns and three rows, with the wide room on top; tap a photo to widen and open it.

With reduced motion

No spring and no movement: the cells change size at once, and captions, card and cross simply fade in.

Pitfalls

  • A CSS grid with fr columns does not animate well: the weights must live in the script and each cell’s position must be computed by hand.
  • The photo goes into a canvas as large as the whole mosaic, but is redrawn to the cell’s size around its subject: with one big drawing a small cell only shows the middle (the floor instead of the tub), with a small one the open room stretches.
  • On resize the mosaic is measured at once and the photos redrawn shortly after, once, not on every event.
  • The photos arrive after the script: each image redraws the mosaic as soon as it has loaded.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 8.1 KB; the libraries: GSAP 28 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