Skip to content
animorio
IT
Back to the library

Power bank cable

Physics, HoverCanvas, GSAPAdvancedCompressed weight: Demo 9.5 KBGSAP 28 KBFreeDownload the zip

The first screen of Ampwell Pack 20, a made-up power bank, on a warm white: the headline «Plug in. Forget it.», the matte graphite pack and, on the floor, a real USB-C cable. The cable is a chain of points held by sticks, written by hand, so it sags, swings, slides and comes to rest, with its shadow following it on the floor. You pick up the plug and bring it to the port on the side of the pack: it snaps in, the pack gives a tiny jolt, a thin ring opens at the port, the bolt appears and the four bars light up one after the other while the percentage climbs to 100. Touched again, the plug pops out and falls back, swinging.

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>
<!--
  "Power bank cable" 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 power bank hero with the cable you drag into the port</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 opening of the page of a made-up power bank, Ampwell Pack 20. A real USB-C cable lies on the floor: it is a
       chain of points held by sticks (Verlet, written by hand), so it sags, swings and rests. Drag its plug into the
       port on the side of the pack: it snaps in, the pack gives a tiny jolt, the four charge bars fill one by one and
       the percentage rolls to 100. Touch the plug again and it pops out and falls. Left alone, a drawn pointer does it -->
  <main class="stage" data-stage>
    <canvas class="cable" data-cable aria-hidden="true"></canvas>

    <header class="nav" data-nav>
      <span class="brand">
        <svg viewBox="0 0 20 20" aria-hidden="true"><rect x="2.5" y="5" width="15" height="10" rx="3"/><path d="M9.6 7.4 7.6 10.4h3l-1.9 2.6"/></svg>
        Ampwell
      </span>
      <nav class="nav__links" aria-label="Main">
        <a href="#" data-link>Packs</a><a href="#" data-link>Cables</a><a href="#" data-link>Support</a>
      </nav>
      <a class="nav__cta" href="#" data-cta><span>Buy · $89</span></a>
    </header>

    <section class="hero">
      <p class="eyebrow" data-rise>Ampwell Pack 20</p>
      <h1 class="title"><span class="line"><span data-line>Plug in.</span></span> <span class="line"><span data-line>Forget it.</span></span></h1>
      <p class="sub" data-rise>Full in 32 minutes. Lasts the whole trip.</p>
    </section>

    <div class="product" data-product>
      <div class="readout" data-readout aria-live="polite">
        <span class="readout__state" data-state>Unplugged</span>
        <span class="readout__pct"><span data-pct>18</span>%</span>
      </div>
      <div class="pack" data-pack>
        <span class="pack__edge" aria-hidden="true"></span>
        <span class="pack__port" data-port aria-hidden="true"></span>
        <span class="pack__name" aria-hidden="true">AMPWELL</span>
        <svg class="pack__bolt" data-bolt viewBox="0 0 16 16" aria-hidden="true"><path d="M9.2 1.8 4.4 9h3.4l-1.2 5.2L11.6 7H8.2z"/></svg>
        <span class="pack__bars" aria-hidden="true"><i data-bar></i><i data-bar></i><i data-bar></i><i data-bar></i></span>
      </div>
      <span class="floor" aria-hidden="true"></span>
    </div>

    <p class="hint" data-hint>Drag the cable into the port</p>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.5v15.2l4.1-3.9 2.7 6 2.6-1.1-2.7-5.9 5.6-.3z"/></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.

31 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 “Power bank cable” 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, at the top the bar with the Ampwell mark, three links and the black Buy · $89 pill that widens on hover; in the middle the product name, the headline in two lines rising from behind a mask, «Plug in.» in black and «Forget it.» in grey, and a line below. Lower down the pack: a matte graphite slab with soft corners, a thread of light on the top edge, the engraved name, the USB-C port on the left side and four unlit bars bottom right; above it, Unplugged and 18%. From the left edge comes a white braided cable lying on the floor, with its steel plug and its shadow. The cable is real physics: a chain of thirty points held to their distance eighteen times a frame, with gravity, friction on the floor and the pack as an obstacle. On hover the plug lifts a little and a glint runs over it; picked up, the cable hangs from the hand and follows it. Near the port the plug snaps in: the pack gives a jolt of a couple of pixels, a thin ring opens at the port, the bolt pops in, the label turns to Charging and the percentage climbs to a hundred lighting the bars one after the other, each with a small hop, up to Full. Touched again, the plug pops out and falls back, swinging. Left alone, a drawn pointer picks up the plug, brings it to the port, waits for the charge, pulls it out, and the next morning the pack is back to 18%.

How it works

The cable

Thirty points in a chain: every frame they move with their own speed (Verlet) and gravity, then eighteen passes pull them back to the length of their link. The first point is fixed off screen to the left; the last one is the plug.

The floor and the pack

Every point below the floor goes back above it and loses part of its sideways speed, so the cable slides and stops; a point inside the pack leaves it by the shortest way, over the top or out of the side.

The grab and the snap

Picked up, the plug chases the hand halfway at every pass, and the cable hangs. When it gets close to the port it locks there: the last point stays still and the one before is pulled straight, like a real strain relief.

The charge

A GSAP tween takes the percentage to a hundred; every quarter lights a bar with a small hop and the label changes, rising.

Values to change

NameFileDefaultWhat it changes
GRAVITYscript.js1700How hard the cable is pulled down, in pixels per second squared.
SEGMENTSscript.js30How many links the cable is made of: more is softer.
SLACKscript.js1.02How much longer the cable is than the shortest way to the port.
STIFFNESSscript.js18How many times per frame the links go back to their length.
FLOOR_FRICTIONscript.js0.82How fast the cable stops sliding on the floor.
SNAPscript.js3.4How close to the port the plug must get to snap in.
CHARGE_TIMEscript.js4.2Seconds to reach 100%.
START_LEVELscript.js18The charge when the page opens, in percent.
CABLEscript.js'#f2f0ea'The colour of the cable.
IDLEscript.js1.2Seconds before the pointer starts by itself.

Try them in the Playground

When to use it

In the opening of the page of a product you plug in: a power bank, a charger, headphones, a lamp, a small appliance; or in a «how it works» section of an electronics shop.

On phones

The measures start from a unit that is the smaller of a hundredth of the width and a hundredth and a third of the height: pack, cable and plug shrink together, the pack widens a little and the bar links disappear. The cable is picked up with the finger, with the same physics.

With reduced motion

No physics and no pointer: the cable is already laid and plugged in, the pack is full and the bars are lit; the headline and the rest fade in.

Pitfalls

  • The pack is measured after the entrance: during it the pack is ten pixels lower and the cable would aim at the wrong port.
  • With the plug held or plugged in, the last point does not move in the link passes: only its neighbour does, otherwise the plug shakes.
  • The start of each stroke of the drawn pointer is read when the stroke starts, not when the timeline is built.
  • A cable in 2D cannot slip sideways like a real one: if it is longer than the way, it folds back on itself on the floor. Left alone, the links ease back to the length that lies straight and every point slides to its place on the line; and the plug leaves the port without jumping up, otherwise it tips over backwards.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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