Pointer Eyes Ball Drop: Dark Card With Falling Balls and Eyes That Follow the Pointer
Goal
Build one section on a white page holding a large dark rounded card centred in the viewport. Along the card's bottom edge sits a pile of coloured balls (an SVG of circles). The balls start above the card, out of sight, and the first time the card enters the viewport (or on load if it is already visible) they drop and bounce once with bounce.out and a random stagger. In the centre, two big white eyes follow the pointer: each black pupil shifts toward the cursor and rotates so its small highlight faces it. With no pointer yet, they look up and to the left. GSAP + ScrollTrigger.
Tech
Vanilla HTML/CSS/JS with ES module imports. gsap (npm) and gsap/ScrollTrigger. No fonts needed (there is no text).
Layout / HTML
<div class="pe">
<section class="pe-stage">
<div class="pe-panel" data-pe-panel>
<svg class="pe-balls" viewBox="0 0 1280 820" preserveAspectRatio="xMidYMax slice" aria-hidden="true">
<circle cx="210" cy="760" r="62" fill="#c7b3f0"/>
<circle cx="330" cy="760" r="58" fill="#e6e0ee"/>
<circle cx="440" cy="760" r="54" fill="#6b2e7a"/>
<circle cx="560" cy="760" r="62" fill="#f2f0f4"/>
<circle cx="668" cy="760" r="58" fill="#c7b3f0"/>
<circle cx="790" cy="760" r="54" fill="#e6e0ee"/>
<circle cx="910" cy="760" r="62" fill="#6b2e7a"/>
<circle cx="1030" cy="760" r="58" fill="#f2f0f4"/>
<circle cx="1140" cy="760" r="54" fill="#c7b3f0"/>
<circle cx="270" cy="660" r="56" fill="#c7b3f0"/>
<circle cx="388" cy="660" r="52" fill="#e6e0ee"/>
<circle cx="500" cy="660" r="48" fill="#6b2e7a"/>
<circle cx="612" cy="660" r="56" fill="#f2f0f4"/>
<circle cx="730" cy="660" r="52" fill="#c7b3f0"/>
<circle cx="846" cy="660" r="48" fill="#e6e0ee"/>
<circle cx="966" cy="660" r="56" fill="#6b2e7a"/>
<circle cx="1084" cy="660" r="52" fill="#f2f0f4"/>
<circle cx="440" cy="566" r="48" fill="#6b2e7a"/>
<circle cx="556" cy="566" r="44" fill="#f2f0f4"/>
<circle cx="790" cy="566" r="40" fill="#c7b3f0"/>
<circle cx="904" cy="566" r="48" fill="#e6e0ee"/>
</svg>
<div class="pe-eyes" aria-hidden="true">
<div class="pe-eye"><div class="pe-pupil"></div></div>
<div class="pe-eye"><div class="pe-pupil"></div></div>
</div>
</div>
</section>
</div>
21 circles in three rows (cy 760 / 660 / 566 in a 0 0 1280 820 viewBox, radii 44 to 62), filled with #c7b3f0, #f2f0f4, #6b2e7a and #e6e0ee.
Styling
:root: --pe-bg:#fff, --pe-panel:#1a1320, --pe-eye:#fbfafc, --pe-pupil:#0d0a10, --pe-eye-size:clamp(110px,15vw,220px), --pe-radius:28px.
.pe-stage:min-height:100svh; display:grid; place-items:center; padding:clamp(16px,4vw,48px)..pe-panel:position:relative; width:min(1200px,100%); height:min(82svh,820px); min-height:420px; background:var(--pe-panel); border-radius:var(--pe-radius); overflow:hidden; display:grid; place-items:center..pe-balls:position:absolute; inset:0; width:100%; height:100%withpreserveAspectRatio="xMidYMax slice"so the pile always rests on the bottom edge..pe-eyes: flex row,gap:clamp(10px,1.6vw,24px),transform:translateY(-14%),pointer-events:none..pe-eye:width:var(--pe-eye-size); aspect-ratio:1; border-radius:50%; background:var(--pe-eye); display:grid; place-items:center..pe-pupil:width:66%; aspect-ratio:1; border-radius:50%; background:var(--pe-pupil);::beforeis the highlight: 16% circle in--pe-eye,top:22%; left:50%; translateX(-50%).- Under 767px: card
height:70svh, eyes34vw.
GSAP effect (be exact)
Build in mount(config) → destroy().
const DEFAULTS = { drop: 900, duration: 1.3, each: 0.04, follow: 6, maxOffset: 0.17 };
Drop: gsap.set(circles, { y: -drop }) (viewBox units), then a paused gsap.to(circles, { y: 0, duration: 1.3, ease: "bounce.out", stagger: { each: .04, from: "random" } }). ScrollTrigger.create({ trigger: panel, start: "top 70%", once: true, onEnter: () => drop.play() }). If the card is already past that line on load, ScrollTrigger fires onEnter immediately.
Eyes: track pointermove (clientX/Y, plus a moved flag). On gsap.ticker, for each eye (skip if off-screen by more than 50px): centre cx, cy from getBoundingClientRect(); target is the pointer, or (cx - w, cy - 0.8h) if the pointer never moved; ang = atan2(ty - cy, tx - cx); d = min(hypot(...) / 6, w * .17); gsap.set(pupil, { x: cos(ang)*d, y: sin(ang)*d, rotation: ang*180/PI + 90 }). The + 90 turns the top-mounted highlight toward the cursor.
If prefers-reduced-motion: reduce matches, the balls are simply in place (no drop); the eyes still follow.
destroy(): remove the ticker callback and the listener, kill the trigger and the tween, clearProps:"transform" on circles and pupils.
Assets / images
None.
Behavior notes
- Ball positions live in the SVG, so the pile scales with the card and stays glued to its floor.
- The eye maths is per element: add more
.pe-eyeanywhere and they all look at the pointer. - Only the prefixed variables are global.
Using this outside its demo page
This component is written as a complete page: that is how the demo is meant to look. If you are dropping it into an existing project, or combining it with other components, these are the things it declares at document level and that you need to move or reconcile first.
- Palette on
:root:--pe-bg,--pe-panel,--pe-eye,--pe-pupil,--pe-eye-size,--pe-radius. Generic names like--ink,--paperor--mutedare defined by many components in this catalogue with different values, and they will also collide with whatever your own project defines. Move them onto the component's wrapper (.my-section { --ink: … }) or keep the prefix. - **Rules on
*, *::before, *::after,html, body**: the demo owns the whole document, so these set the box model and resets. Dropped into an existing project they restyle the entire page, not just this section. Re-target them at the component's wrapper before using it.