Skip to content
animorio
IT
Back to the library

Swinging pearl earrings

Physics, HoverGSAP, CSS onlyMediumCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

The product card of a made-up jewellery atelier, Ferne Atelier, in the premium style of the interface pieces: in the photo a pair of freshwater pearl drops hangs from a brass rod, and each earring is a chain of three pieces (the ear wire, the hoop, the pearl) in a small hand-written physics world, with gravity, inertia and air drag. Drag the card and the pearls lag behind, swing and settle as the card springs back into place; a passing pointer brushes them; picking Gold, Silver or Rose changes the metal, the thumb slides on a spring, the price rolls and the earrings chime; Add to bag dips the card a touch and the bag count pops up.

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>
<!--
  "Swinging pearl earrings" 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 earring product card with pearls that swing as you drag 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" data-stage>
    <!-- the product card of a made-up jewellery atelier. A pair of pearl drops hangs from a brass rod in the photo
         well: each earring is a chain of three pieces (the ear wire, the hoop, the pearl) in a small hand-written
         physics world. Drag the card and they swing with its inertia, brush them with the pointer, change the metal
         and they chime; adding to the bag dips the card -->
    <article class="card" data-card aria-label="Tide pearl drops">
      <div class="well" data-well>
        <span class="well__light" aria-hidden="true"></span>
        <svg class="jewel" data-svg aria-hidden="true">
          <defs>
            <linearGradient id="metal" x1="0" y1="0" x2="1" y2="1">
              <stop offset="0" data-m1 stop-color="#f6e2a8"></stop>
              <stop offset="0.45" data-m2 stop-color="#d4ab5c"></stop>
              <stop offset="1" data-m3 stop-color="#9b7431"></stop>
            </linearGradient>
            <radialGradient id="pearl" cx="0.4" cy="0.36" r="0.7" fx="0.34" fy="0.28">
              <stop offset="0" stop-color="#ffffff"></stop>
              <stop offset="0.38" stop-color="#f6f0e7"></stop>
              <stop offset="0.8" stop-color="#ddd1c0"></stop>
              <stop offset="1" stop-color="#c3b5a1"></stop>
            </radialGradient>
            <radialGradient id="sheen" cx="0.5" cy="0.5" r="0.5">
              <stop offset="0.62" stop-color="#f3c9d4" stop-opacity="0"></stop>
              <stop offset="0.9" stop-color="#e9b9c7" stop-opacity="0.5"></stop>
              <stop offset="1" stop-color="#bcd3e6" stop-opacity="0.35"></stop>
            </radialGradient>
            <linearGradient id="rod" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#efe2c4"></stop>
              <stop offset="0.5" stop-color="#b99a62"></stop>
              <stop offset="1" stop-color="#7d6238"></stop>
            </linearGradient>
            <filter id="soft" x="-50%" y="-50%" width="200%" height="200%">
              <feColorMatrix type="matrix" values="0 0 0 0 0.28  0 0 0 0 0.22  0 0 0 0 0.16  0 0 0 0.32 0"></feColorMatrix>
              <feGaussianBlur stdDeviation="2.6"></feGaussianBlur>
            </filter>
          </defs>
          <use href="#pair" class="jewel__shadow" data-shadow filter="url(#soft)"></use>
          <g id="pair" data-pair>
            <rect class="rod" data-rod fill="url(#rod)"></rect>
            <rect class="rod__glint" data-rodglint></rect>
          </g>
        </svg>
        <div class="bag" data-bag aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M5.2 7h9.6l-.8 9.2H6Z"></path><path d="M7.6 7V5.8a2.4 2.4 0 0 1 4.8 0V7"></path></svg>
          <span class="bag__n" data-bagn>0</span>
        </div>
        <span class="tag" data-tagline>Freshwater pearl</span>
      </div>

      <div class="info">
        <div class="info__row">
          <div>
            <p class="brand">Ferne Atelier</p>
            <h1 class="name">Tide pearl drops</h1>
          </div>
          <p class="price" aria-live="polite"><span class="price__win"><span class="price__n" data-price>$148</span></span></p>
        </div>

        <div class="metal" role="radiogroup" aria-label="Metal" data-metals>
          <span class="metal__thumb" data-thumb aria-hidden="true"><span class="metal__thumb-face"></span></span>
          <button class="metal__opt is-on" type="button" role="radio" aria-checked="true" data-metal="gold" data-autoclic>Gold</button>
          <button class="metal__opt" type="button" role="radio" aria-checked="false" data-metal="silver" data-autoclic>Silver</button>
          <button class="metal__opt" type="button" role="radio" aria-checked="false" data-metal="rose" data-autoclic>Rose</button>
        </div>

        <button class="add" type="button" data-add data-autoclic>
          <span class="add__face" data-addface>
            <span class="add__words" data-addwords>Add to bag</span>
            <svg class="add__icon" viewBox="0 0 16 16" aria-hidden="true">
              <path class="add__plus" data-plus d="M8 3.5v9M3.5 8h9"></path>
              <path class="add__check" data-check pathLength="1" d="M3.4 8.4l3 3 6.2-6.6"></path>
            </svg>
          </span>
        </button>
      </div>
    </article>

    <p class="hint">Drag the card, brush the pearls.</p>
    <p class="sr" aria-live="polite" data-live></p>
    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></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.

27 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 “Swinging pearl earrings” 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 an ivory ground sits a warm white card with soft layered shadows and a thin edge that catches the light. At the top the photo: a sand coloured studio sweep with a thin brass rod, and hanging from it two pearl drop earrings, each with a gold ear wire hooked over the rod, an oval gold hoop and a white pearl with a pink and blue sheen on its rim; below, on the sweep, their blurred shadow. In one corner the glass circle with a drawn bag, in the other the Freshwater pearl pill. Under the photo Ferne Atelier, the name Tide pearl drops and the price, $148; then the metal picker with Gold, Silver and Rose and the dark Add to bag button with its plus. A drawn pointer takes the card and carries it left, right and back to the middle: the card lifts, tilts with its speed and the pearls lag behind, swing on their own and slowly calm down as the card springs back with a small bounce. The pointer passes between the pearls and sets them swinging; it picks Silver, then Rose: the white thumb slides with a bounce and squashes a little, the earrings change metal, a glint runs along the rod, the price rolls to $118 and $156 and the earrings chime. Pressing Add to bag squashes the button, the words become Added with a tick that draws itself, the card dips a touch so the pearls swing, and the number pops on the bag; then it goes back to Gold. The real pointer can drag the card, brush the pearls and light a glow that follows it on the sweep.

How it works

A chain of points with Verlet

Each earring is made of four points: the first is fixed on the rod, the other three (the end of the ear wire, the bottom of the hoop, the pearl) move with Verlet integration, which only remembers the previous position: velocity is the difference between the two, gravity is added each step and the air takes a little away. After the step, five rounds of constraints put each link back to its length, moving the lighter point more.

The world moves with the card

The card has its own hand-written spring for offset, tilt and lift. Each step the point on the rod is carried into page coordinates through the card’s transform: the pearls, living in the same world, lag behind by inertia on their own. To draw them the sum runs backwards and the pieces go into the photo’s SVG, the hoop rotated along its link and the pearl only moved, so its light stays where the lamp is.

A rubber band that never leaves

While dragging, the card follows the pointer up to half of the free room and then less and less, like a rubber band that never passes the margin worked out on every resize with tilt and lift already inside; let go, it returns to the middle on a lightly damped spring, and the bounce shows in the pearls.

Values to change

NameFileDefaultWhat it changes
GRAVITYscript.js1How heavy the pearls are: higher, they swing faster.
DAMPINGscript.js1How quickly they calm down: higher, they stop sooner.
REACHscript.js64How many pixels at most the card travels when dragged, then it pulls like a rubber band.
TILTscript.js1How much the card tilts with its speed (0 stays straight).
LIFTscript.js1.025How much the card lifts while you hold it (1 for none).
BRUSHscript.js1How much a passing pointer moves the pearls (0 none).
CHIMEscript.js1How much the earrings chime when the metal changes (0 none).
HOLDscript.js1.6The seconds of pause before the autopilot starts again.
--pagestyle.css#efebe4The ivory of the page.
--accentstyle.css#b08a4aThe brass of the bag count and of the keyboard focus ring.

Try them in the Playground

When to use it

For the product card or grid of a shop selling jewellery, accessories or small hanging objects: whoever looks picks up the card and feels the weight of the product, tries the metals and puts it in the bag.

On phones

The same physics with a finger: the card is dragged by touch and sizes the photo on the height too; the drag room is worked out on the screen so the tilted card never leaves the side, and the line below hides under 480 pixels.

With reduced motion

No swinging or moving: the earrings hang still, the card does not drag, the metal, the price and the button change with fades.

Pitfalls

  • The pearl moves without rotating: with the radial gradient in a rotated group the highlight would turn with the earring and the light would look fake.
  • The earrings’ shadow is a use element of the same group with a filter that darkens and blurs it: it updates itself every frame without drawing twice.
  • The drag margin must count tilt and lift: without them, on a 390 phone the tilted card left the side.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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