060

Twang Lanyard

£10 or the whole Vault, £99

A two-leg SVG lanyard simulation that lets a weighted event pass fall, whip, twist, and settle through damped rope constraints.

advanced
8 more details
rope-physicsconstraint-solversvg-animationtouch-dragvelocity-reactiveviewport-aware-ticker3d-transformskeyboard-navigation

This demo reads better at your own screen size than in the frame below:

Released

About this effect

A tactile event-pass effect that couples two independently simulated SVG strap chains to one weighted rigid badge using GSAP core. Grab the pass and release a hard sideways whip to send delayed S-curves through both legs, kick the connector, twist the pass through centre, and resolve into decreasing pendulum swings.

Twang Lanyard - GSAP animation effect preview

What's included

8 items
  • Dual rope chains — independent Verlet points feed one shared connector
  • Weighted badge dynamics — translation, rotation, gravity, and angular release velocity
  • Layered velocity response — perspective, highlight direction, shadow travel, and connector tension
  • Real touch dragging — the same grab-and-whip simulation runs on coarse pointers with stronger damping
  • Keyboard tugs — arrow keys apply directional impulses while Enter and Space trigger a full twang
  • Configurable physics — tune gravity, damping, stiffness, solver iterations, swing strength, and strap copy
  • Static fallback — polished hanging SVG and pass remain visible without JavaScript or with reduced motion
  • Lifecycle-safe setup — per-instance listeners, visibility observer, ticker, resize timer, matchMedia, and GSAP context all revert cleanly

Perfect for

5 use cases
  • Conference landing pages with a tactile attendee-pass hero
  • Festival and culture sites with a branded interaction visitors can immediately understand
  • Speaker announcements with a memorable portrait-led identity treatment
  • Event registration confirmations with a playful reward moment
  • Portfolio experiments demonstrating DOM and SVG constraint physics without canvas

How it works

2 sections

Each strap is a chain of Verlet points joined by fixed-distance constraints. The two lower endpoints repeatedly solve against a shared attachment point on a rigid badge body, so a fast release travels through the legs with a visible delay before pulling the connector taut.

GSAP's ticker advances the fixed-step simulation and core setters render the SVG path geometry, badge translation and rotation, perspective tilt, moving light, shadow, and connector scale. The return motion comes from gravity, damping, and constraint relaxation rather than an elastic easing preset.

Difficulty Advanced
Includes HTML + JS + CSS source, documentation, AI setup prompt, lifetime updates

Lighthouse, as measured

Google Lighthouse on this effect's demo, from the latest scan. A measurement of the demo as shipped, not a promise for your page.

Accessibility
100
Best practices
100

No performance score, on purpose. That figure depends on how you deploy: your server's compression and caching, your CDN, the connection and the device doing the test, none of which the code controls. The same page can score very differently on two consecutive runs, so measure it where it will live.

Paid effect

Purchase to unlock the code.

Buying Twang Lanyard opens the HTML, CSS and JavaScript source, the full documentation, an AI setup prompt for your editor, and every update we ship to it. Standard license: unlimited personal and commercial projects. Every paid product is tested for desktop and mobile layouts, reduced-motion handling, animation cleanup and keyboard controls wherever there is something to operate.

£10 Standard license, unlimited projects

Browse free effects

Or the whole library: the Vault, £99, one payment.

Documentation

Quick Start

1. Add to your HTML <head>:

Code snippet omitted: it ships with the download.

2. Add before the closing </body> tag:

Code snippet omitted: it ships with the download.

3. Add the effect structure to your <body>:

Code snippet omitted: it ships with the download.

The complete card artwork, real portrait, scannable GSAP Vault QR code, connector, strap edge treatment, and responsive sizing are in index.html and assets/style.css.

Using It With Your Own Design

What the effect needs from your markup: One [data-lanyard] root containing [data-lanyard-svg], exactly two [data-lanyard-path] paths, [data-lanyard-badge], [data-lanyard-connector], and [data-lanyard-face]. Strap text is optional; every [data-lanyard-label] receives the configured repeated label. Keep the badge and connector inside the root, but the visual content inside the face is entirely yours. Use unique SVG path IDs when placing more than one lanyard on a page.

What is only the demo's styling: The Afterlight branding, Unsplash portrait, QR destination, pass typography, black stage, and palette can all be replaced or removed. The script never queries those decoration classes; its API is exclusively the documented data- hooks.

CSS the effect depends on: Keep the structural classes shown in Quick Start, or carry their layout rules into your own selectors. The root must be a positioned, clipped interaction area with a real height and touch-action: none; the bundled class defaults to 100svh, and you can override that height when embedding it in a section. The SVG must cover that area. The badge must be absolutely positioned; in the live state ([data-state="live"]) it must use top: 0, left: 0 because the simulation writes pixel transforms. Preserve transform-style: preserve-3d on the face for velocity tilt, transform-origin: 50% 100% on the connector, and set --connector-reach on the root to the pixel distance from the badge's top edge to the rope attachment point. Include readable static path geometry and a static badge position outside [data-state="live"] so no-JS and reduced-motion visitors receive a complete hanging pass.

Options

Attribute Values Default Description
data-gravity Positive number 1850 Downward acceleration in pixels per second squared
data-damping 0.9 to < 1 0.989 Desktop velocity retained per fixed simulation step; lower values settle sooner
data-touch-damping 0.9 to < 1 0.982 Coarse-pointer damping; intentionally stronger than desktop by default
data-stiffness 0.2 to 1 0.94 Fraction of strap-length error corrected per solver pass
data-iterations 3 to 14 9 Desktop constraint passes per step; more passes make the straps pull taut sooner
data-touch-iterations 3 to 14 7 Coarse-pointer constraint passes per step
data-swing Positive number 1 Multiplier for pointer-release and keyboard impulse strength
data-strap-label Text AFTERLIGHT Word repeated along optional [data-lanyard-label] text paths

On touch devices data-touch-damping supplies the stronger damping value, data-touch-iterations uses fewer solver passes, and the script builds shorter chains.

Data Hooks

Hook Purpose
[data-lanyard] Instance root, configuration source, keyboard surface, and public API host
[data-lanyard-svg] SVG whose viewBox is synchronized to the rendered root
[data-lanyard-path] The two strap centreline paths rewritten each frame
[data-lanyard-label] Optional text paths populated from data-strap-label
[data-lanyard-badge] Draggable rigid badge body receiving x, y, and z rotation
[data-lanyard-face] Badge face receiving velocity-reactive X/Y perspective and light variables
[data-lanyard-connector] Connector receiving tension scale and counter-kick rotation

Accessibility

  • The root is keyboard focusable and has visible focus styling.
  • Arrow keys apply directional tugs. Enter and Space trigger the same strong sideways response as a pointer whip.
  • Add an aria-label or aria-describedby prompt that explains both drag and keyboard controls.
  • Pointer interaction uses Pointer Events, so mouse, pen, and touch share one path. The clipped stage lets visitors pull the pass below the frame without creating page overflow.
  • prefers-reduced-motion: reduce creates no simulation, pointer listeners, resize listener, or ticker. The authored static lanyard remains visible.
  • Without JavaScript, the same static SVG paths and pass remain fully composed.
  • The pass content remains semantic HTML and can carry meaningful attendee or event text.

Performance Notes

  • The simulation uses a fixed 1/120 second step with a catch-up cap for stable constraints across refresh rates.
  • SVG and DOM nodes are reused; the effect creates no per-frame elements and uses no canvas.
  • An IntersectionObserver pauses the GSAP ticker whenever the lanyard leaves the viewport.
  • Mobile uses shorter chains and stronger damping while preserving the same touch-drag mechanic.
  • Keep data-iterations at or below 14; higher values add CPU cost with little visible improvement.

Demo Image Credit

The bundled speaker portrait is an art-directed crop of an Unsplash photograph. The QR code is generated locally and encodes https://gsapvault.com/.

Dependencies

Required:

  • GSAP core 3.12+ (demo uses 3.15.0)

Not required:

  • Draggable
  • InertiaPlugin
  • ScrollTrigger
  • Lenis
  • Canvas or a collision library

Worked examples, the events and programmatic API, and the class reference ship with the download, alongside the full source.