{
  "id": "magnetic-buttons",
  "kind": "element",
  "title": "Magnetic buttons",
  "summary": "Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.",
  "url": "https://enrichr.dev/elements/magnetic-buttons.html",
  "section": "band",
  "techniques": [
    "pointer-interaction"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "playful",
    "modern",
    "polished"
  ],
  "intents": [
    "magnetic button hover effect",
    "button follows cursor",
    "spring pull button",
    "cursor attracted cta button",
    "label parallax button"
  ],
  "status": "tested",
  "params": [
    {
      "key": "accent",
      "label": "Accent colour",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "strength",
      "label": "Pull strength",
      "type": "range",
      "min": 0.1,
      "max": 0.8,
      "step": 0.05,
      "value": 0.4
    },
    {
      "key": "radius",
      "label": "Magnet radius (px)",
      "type": "range",
      "min": 20,
      "max": 200,
      "step": 5,
      "value": 80
    },
    {
      "key": "spring",
      "label": "Spring stiffness",
      "type": "range",
      "min": 0.04,
      "max": 0.4,
      "step": 0.01,
      "value": 0.12
    },
    {
      "key": "labelShift",
      "label": "Label parallax",
      "type": "range",
      "min": 1,
      "max": 3,
      "step": 0.1,
      "value": 1.8
    }
  ],
  "license": "Free to use in personal and client projects during the preview. Final licence terms will be published here before any paid tier starts; ask before reselling the code as a collection.",
  "contract": "function mount(root, opts) -> { update(partialOpts), destroy() }; root must contain the element markup",
  "exports": {
    "claude": "Add the \"Magnetic buttons\" element to this project.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSteps:\n1. Look at the project first to see its framework and where components, styles and static files live. Follow its conventions.\n2. Fetch https://enrichr.dev/elements/magnetic-buttons.json if you can read URLs (fields: source.markup, source.css, source.js, params); otherwise use the source at the end of this message.\n3. Add the files, mount it where I tell you (default: the top of the home page), and pass the settings below as the opts.\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n5. Run the dev server and check it. with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "chatgpt": "I want the \"Magnetic buttons\" element on my website. Below is its complete source. Please:\n1. Build one self-contained index.html that I can open locally to see it working (put the CSS in a <style> tag and the JavaScript in a <script> tag, with the markup in the body).\n2. Then explain, step by step, which parts go where in my own site, and how to mount it. My stack is: [tell me yours, or say \"plain HTML\"].\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "cursor": "Add the \"Magnetic buttons\" element to this codebase.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nUse Composer / agent mode. First search the repo for how components, styles and scripts are organised, then add the files in the matching places, mount it on the page I name, and run the app to confirm it works. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nOptional: save this as .cursor/rules/enrichr-magnetic-buttons.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Magnetic buttons element\nalwaysApply: false\n---\nmount(root, opts) expects the element markup inside root and returns { update, destroy }. Always call destroy() on unmount and never edit the ef- class names.",
    "v0": "Create a Next.js (App Router) client component for the \"Magnetic buttons\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- magnetic-buttons.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nUse this component as the wrapper (adjust the import paths):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./magnetic-buttons\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function MagneticButtons(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRender it on the home page so I can see it. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "lovable": "Add the \"Magnetic buttons\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- magnetic-buttons.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nWrapper component (src/components/MagneticButtons.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./magnetic-buttons\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function MagneticButtons(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRemove the \"use client\" line if it is not needed. Show it on the home page. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "bolt": "Create a small Vite project (vanilla JavaScript, no framework unless I already have one) that shows the \"Magnetic buttons\" element.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, then a script tag), style.css (the CSS below), magnetic-buttons.js (the JavaScript below) and main.js that sets the container's innerHTML to the markup and calls mount(container, opts) with the settings below. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "replit": "Create a new HTML, CSS and JavaScript Repl that shows the \"Magnetic buttons\" element. No packages, no server code.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, link style.css, load magnetic-buttons.js and then main.js), style.css (the CSS below), magnetic-buttons.js (the JavaScript below), main.js (sets the container's innerHTML to the markup, then calls mount(container, opts) with the settings below). Press Run to preview. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "figma": "Designer handoff notes for the \"Magnetic buttons\" element (Enrichr Library). Figma cannot run this JavaScript inside a design file, so use it as a motion reference and hand the code to a developer.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nWhat it does: A pointer listener on the wrapper stores the cursor position. For each button the script measures its centre and, if the cursor is within the magnet radius, sets a target offset equal to the distance times the strength; outside it, the target is zero. One requestAnimationFrame loop then integrates a damped spring per button toward its target and writes --x and --y, plus --lx and --ly for the label, which moves further than the shell. The stylesheet applies them as translate3d and fades in a filled layer when the pointer is near. The loop stops itself once every button is at rest.\nAccessibility: These are real buttons with a visible focus ring, so keyboard users get the same affordance without motion. Movement is mouse and pen only; touch and prefers-reduced-motion get no displacement. The pull is small enough that hit targets stay stable, and the label keeps strong contrast against both states.\n\nTunable settings:\n- Accent colour: color, default #e6ff55\n- Pull strength: range 0.1 to 0.8, step 0.05, default 0.4\n- Magnet radius (px): range 20 to 200, step 5, default 80\n- Spring stiffness: range 0.04 to 0.4, step 0.01, default 0.12\n- Label parallax: range 1 to 3, step 0.1, default 1.8\n\nCurrent settings:\n{{SETTINGS}}\n\nFor the developer: Element contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nIn Figma:\n- Draw the resting state as a frame and the end state as a second frame; link them with Smart Animate to show the motion in a prototype.\n- Put the settings above in the frame's notes or Dev Mode annotations so the developer matches them.\n- Link https://enrichr.dev/elements/magnetic-buttons.html in the handoff: the live demo and the copy-ready code are there. Developers can paste the prompts for Claude, Cursor or v0 from the Export menu.\nNothing is copied from another designer's file; this is original code from Enrichr.",
    "framer": "Add the \"Magnetic buttons\" element to Framer as a code component. Framer code components are React, so wrap the vanilla code like this. Check it in the Framer editor, as Framer's component API can change.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. In Framer: Assets > Code > New component. Name it MagneticButtons.\n2. Paste the JavaScript below into a separate code file named magnetic-buttons.js in the same project, with  export { mount };  and  export const markup = \"<the markup string>\";  added. Put the CSS into the component as a <style> tag.\n3. Component:\n```tsx\nimport { addPropertyControls, ControlType } from \"framer\"\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./magnetic-buttons\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function MagneticButtons(props: any) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n\naddPropertyControls(MagneticButtons, {\n  accent: { type: ControlType.Color, title: \"Accent colour\", defaultValue: \"#e6ff55\" },\n  strength: { type: ControlType.Number, title: \"Pull strength\", min: 0.1, max: 0.8, step: 0.05, defaultValue: 0.4 },\n  radius: { type: ControlType.Number, title: \"Magnet radius\", min: 20, max: 200, step: 5, defaultValue: 80 },\n  spring: { type: ControlType.Number, title: \"Spring stiffness\", min: 0.04, max: 0.4, step: 0.01, defaultValue: 0.12 },\n  labelShift: { type: ControlType.Number, title: \"Label parallax\", min: 1, max: 3, step: 0.1, defaultValue: 1.8 },\n})\n```\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "webflow": "Add the \"Magnetic buttons\" element to a Webflow site with an Embed element. Test it on the published or preview site: scripts in embeds may not run inside the Designer canvas.\n\nThis is the \"Magnetic buttons\" element from the Enrichr Library: Buttons that pull toward the pointer on a spring while the inner label drifts further for a parallax feel.\nPage: https://enrichr.dev/elements/magnetic-buttons.html\nMachine-readable spec: https://enrichr.dev/elements/magnetic-buttons.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. Add an Embed element where it should appear. Paste a <style> block with the CSS, one container <div id=\"enrichr-magnetic-buttons\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-magnetic-buttons\"), { ...your settings... });\n   (set the container's innerHTML to the markup first, as in the contract).\n2. Embed elements have a size limit (check Webflow's current number). If the code is longer, host the JS and CSS as files and link them from Custom code in the page settings, then keep only the container and the mount call in the Embed.\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}"
  },
  "exportTools": [
    "claude",
    "chatgpt",
    "cursor",
    "v0",
    "lovable",
    "bolt",
    "replit",
    "figma",
    "framer",
    "webflow"
  ],
  "accessibility": "These are real buttons with a visible focus ring, so keyboard users get the same affordance without motion. Movement is mouse and pen only; touch and prefers-reduced-motion get no displacement. The pull is small enough that hit targets stay stable, and the label keeps strong contrast against both states.",
  "performance": "One rAF loop runs only while a button is moving. Each frame writes four custom properties per button and only transforms and opacity change. Layout is read once per pointer move per button, so keep the button count small.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-mgb\">\n  <div class=\"ef-mgb__wrap\"><div class=\"ef-mgb__row\"></div></div>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-mgb { width: 100%; }\n.ef-mgb__wrap { box-sizing: border-box; width: 100%; min-height: 18rem; padding: 1.5rem; border-radius: 1rem; display: flex; align-items: center; justify-content: center; overflow: hidden; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.ef-mgb__row { display: flex; flex-wrap: wrap; gap: 2.2rem; align-items: center; justify-content: center; padding: 1rem; }\n.ef-mgb__btn { --x: 0px; --y: 0px; --lx: 0px; --ly: 0px; --a: 0; position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 8rem; padding: 1rem 1.7rem; border: 1.5px solid var(--ef-acc, #e6ff55); border-radius: 999px; background: transparent; color: var(--ef-acc, #e6ff55); font: inherit; font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; cursor: pointer; transform: translate3d(var(--x), var(--y), 0); will-change: transform; outline: none; overflow: hidden; transition: color 250ms, box-shadow 250ms; }\n.ef-mgb__btn::before { content: \"\"; position: absolute; inset: 0; border-radius: inherit; background: var(--ef-acc, #e6ff55); opacity: var(--a); transform: translate3d(calc(var(--x) * -0.4), calc(var(--y) * -0.4), 0); transition: opacity 250ms; }\n.ef-mgb__btn.is-near { color: #0c1e18; }\n.ef-mgb__lbl { position: relative; display: block; transform: translate3d(var(--lx), var(--ly), 0); pointer-events: none; }\n.ef-mgb__btn:focus-visible { box-shadow: 0 0 0 3px #0c1e18, 0 0 0 5px var(--ef-acc, #e6ff55); }\n.ef-mgb__btn:focus-visible::before { opacity: 0.18; }\n@media (prefers-reduced-motion: reduce) { .ef-mgb__btn { transform: none; } .ef-mgb__lbl { transform: none; } .ef-mgb__btn::before { transform: none; } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Magnetic buttons: buttons that pull toward the pointer on a spring, with the inner label drifting further than the shell (parallax).\n// A single rAF loop integrates a spring per button and only runs while something is moving. Mouse and pen only; keyboard focus\n// shows a ring, and reduced motion keeps the colour fill but no movement. Pointer tracking is on the wrapper, so it works in a clipped box.\n// mount(root, { background, accent, strength (0.1-0.8), radius (px), spring (0.04-0.4), labelShift (1-3) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-mgb__wrap\");\n  var row = root.querySelector(\".ef-mgb__row\");\n  var opts = {}, items = [], raf = 0, ptr = null, offs = [];\n  var NAMES = [\"Get started\", \"Explore\", \"Say hello\"];\n\n  function build() {\n    row.textContent = \"\";\n    items = [];\n    NAMES.forEach(function (name) {\n      var b = document.createElement(\"button\");\n      b.type = \"button\"; b.className = \"ef-mgb__btn\";\n      var l = document.createElement(\"span\"); l.className = \"ef-mgb__lbl\"; l.textContent = name;\n      b.appendChild(l); row.appendChild(b);\n      items.push({ el: b, x: 0, y: 0, vx: 0, vy: 0, tx: 0, ty: 0 });\n    });\n  }\n  function frame() {\n    raf = 0;\n    var busy = false, k = opts.spring, damp = 0.78;\n    items.forEach(function (it) {\n      it.vx = (it.vx + (it.tx - it.x) * k) * damp; it.vy = (it.vy + (it.ty - it.y) * k) * damp;\n      it.x += it.vx; it.y += it.vy;\n      var rest = Math.abs(it.tx - it.x) < 0.05 && Math.abs(it.ty - it.y) < 0.05 && Math.abs(it.vx) < 0.05 && Math.abs(it.vy) < 0.05;\n      if (rest) { it.x = it.tx; it.y = it.ty; it.vx = it.vy = 0; } else busy = true;\n      var s = it.el.style;\n      s.setProperty(\"--x\", it.x.toFixed(2) + \"px\"); s.setProperty(\"--y\", it.y.toFixed(2) + \"px\");\n      s.setProperty(\"--lx\", (it.x * (opts.labelShift - 1)).toFixed(2) + \"px\"); s.setProperty(\"--ly\", (it.y * (opts.labelShift - 1)).toFixed(2) + \"px\");\n    });\n    if (busy) raf = requestAnimationFrame(frame);\n  }\n  function kick() { if (!raf) raf = requestAnimationFrame(frame); }\n  function aim() {\n    items.forEach(function (it) {\n      var near = false, tx = 0, ty = 0;\n      if (ptr) {\n        var r = it.el.getBoundingClientRect();\n        var cx = r.left + r.width / 2 - it.x, cy = r.top + r.height / 2 - it.y;\n        var dx = ptr.x - cx, dy = ptr.y - cy;\n        if (Math.abs(dx) < r.width / 2 + opts.radius && Math.abs(dy) < r.height / 2 + opts.radius) { near = true; tx = dx * opts.strength; ty = dy * opts.strength; }\n      }\n      if (reduce) { tx = 0; ty = 0; }\n      it.tx = tx; it.ty = ty;\n      it.el.style.setProperty(\"--a\", near ? \"1\" : \"0\");\n      it.el.classList.toggle(\"is-near\", near);\n    });\n    kick();\n  }\n  function mv(e) { if (e.pointerType === \"touch\") return; ptr = { x: e.clientX, y: e.clientY }; aim(); }\n  function lv() { ptr = null; aim(); }\n  wrap.addEventListener(\"pointermove\", mv);\n  wrap.addEventListener(\"pointerleave\", lv);\n  offs.push(function () { wrap.removeEventListener(\"pointermove\", mv); wrap.removeEventListener(\"pointerleave\", lv); });\n\n  function update(next) {\n    var first = !items.length;\n    opts = Object.assign({ background: \"#0c1e18\", accent: \"#e6ff55\", strength: 0.4, radius: 80, spring: 0.12, labelShift: 1.8 }, opts, next || {});\n    wrap.style.background = opts.background;\n    wrap.style.setProperty(\"--ef-acc\", opts.accent);\n    if (first) build();\n  }\n  function destroy() {\n    offs.forEach(function (f) { f(); }); offs = [];\n    if (raf) cancelAnimationFrame(raf); raf = 0;\n  }\n  update(o);\n  return { update: update, destroy: destroy };\n}"
  }
}