← Blurr Motion nav-magnetic-links-playful
Categorie navs Tier 1 Techniek #12 Deps gsap

Motion Lab / Navs / magnetic-links / playful

Hover the pills — they follow your cursor with a playful bounce.

1. Mechanisme — kopieer 1-op-1, geen styling-keuzes
// Mechanisme: nav-magnetic-links-playful
import gsap from 'https://esm.sh/gsap@3.12.5';
document.querySelectorAll('[data-magnetic]').forEach(el => {
  el.addEventListener('mousemove', e => {
    const r = el.getBoundingClientRect();
    const x = (e.clientX - r.left - r.width / 2) * 0.5;
    const y = (e.clientY - r.top - r.height / 2) * 0.5;
    gsap.to(el, { x, y, duration: 0.5, ease: 'back.out(1.7)' });
  });
  el.addEventListener('mouseleave', () => gsap.to(el, { x: 0, y: 0, duration: 0.7, ease: 'elastic.out(1,0.4)' }));
});
2. Skeleton — DOM + class-namen, mag herschikken
<!-- Skeleton: nav-magnetic-links-playful -->
<nav>
  <a data-magnetic href="#">Link 1</a>
  <a data-magnetic href="#">Link 2</a>
</nav>
3. Styling-template — verplicht eigen invulling per merk
/* Styling: nav-magnetic-links-playful */
[data-magnetic] { display: inline-block; padding: 0.5rem 1.5rem; border-radius: 999px; background: #FF4A1C; color: white; }