{
  "id": "distorted-link-hover",
  "kind": "element",
  "title": "Distorted link hover",
  "summary": "Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.",
  "url": "https://enrichr.dev/elements/distorted-link-hover.html",
  "section": "nav",
  "techniques": [
    "pointer-interaction",
    "text-animation"
  ],
  "stack": [
    "Vanilla JS",
    "SVG filter",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "playful",
    "kinetic"
  ],
  "intents": [
    "distorted text hover",
    "liquid wobble link effect",
    "svg displacement map menu hover",
    "heat haze text effect",
    "warp underline on hover"
  ],
  "status": "tested",
  "params": [
    {
      "key": "items",
      "label": "Links (comma separated)",
      "type": "text",
      "value": "Work, Studio, Journal, About, Contact"
    },
    {
      "key": "strength",
      "label": "Distortion strength (px)",
      "type": "range",
      "min": 0,
      "max": 60,
      "step": 1,
      "value": 24
    },
    {
      "key": "idle",
      "label": "Idle ripple",
      "type": "select",
      "options": [
        [
          "1",
          "On"
        ],
        [
          "0",
          "Off"
        ]
      ],
      "value": "1"
    },
    {
      "key": "color",
      "label": "Text colour",
      "type": "color",
      "value": "#fbf8f1"
    },
    {
      "key": "accent",
      "label": "Hover and underline colour",
      "type": "color",
      "value": "#e6ff55"
    }
  ],
  "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 \"Distorted link hover\" element to this project.\n\nThis is the \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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/distorted-link-hover.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 \"Distorted link hover\" 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 \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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 \"Distorted link hover\" element to this codebase.\n\nThis is the \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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-distorted-link-hover.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Distorted link hover 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 \"Distorted link hover\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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- distorted-link-hover.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 \"./distorted-link-hover\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function DistortedLinkHover(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 \"Distorted link hover\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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- distorted-link-hover.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/DistortedLinkHover.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./distorted-link-hover\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function DistortedLinkHover(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 \"Distorted link hover\" element.\n\nThis is the \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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), distorted-link-hover.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 \"Distorted link hover\" element. No packages, no server code.\n\nThis is the \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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 distorted-link-hover.js and then main.js), style.css (the CSS below), distorted-link-hover.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 \"Distorted link hover\" 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 \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.json\n\nWhat it does: Each link gets its own SVG filter made of an feTurbulence noise source feeding an feDisplacementMap, which pushes the pixels of the link sideways and up and down by the noise value. JavaScript animates the noise frequency and the displacement scale every frame. On hover the effect jumps to full strength and then eases down to a gentle steady wobble; on leave it fades to zero. Once a link is calm the filter is removed from it completely, so resting text is crisp and costs nothing. The underline is a pseudo element inside the link, so it warps with the letters. With idle ripple on, one link pulses by itself every few seconds so the effect is visible without a pointer.\nAccessibility: Links are normal anchors, so keyboard focus triggers the same ripple as hover and the colour and underline change give a clear focus state. The text is never replaced, only displaced visually. With reduced motion there is no filter at all: hover and focus just change the colour and draw the underline. Anchors that point to # are kept from jumping the page in demos.\n\nTunable settings:\n- Links (comma separated): text, default Work, Studio, Journal, About, Contact\n- Distortion strength (px): range 0 to 60, step 1, default 24\n- Idle ripple: select (On / Off), default 1\n- Text colour: color, default #fbf8f1\n- Hover and underline colour: color, default #e6ff55\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/distorted-link-hover.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 \"Distorted link hover\" 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 \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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 DistortedLinkHover.\n2. Paste the JavaScript below into a separate code file named distorted-link-hover.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 \"./distorted-link-hover\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function DistortedLinkHover(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(DistortedLinkHover, {\n  items: { type: ControlType.String, title: \"Links (comma separated)\", defaultValue: \"Work, Studio, Journal, About, Contact\" },\n  strength: { type: ControlType.Number, title: \"Distortion strength\", min: 0, max: 60, step: 1, defaultValue: 24 },\n  idle: { type: ControlType.Enum, title: \"Idle ripple\", options: [\"1\",\"0\"], optionTitles: [\"On\",\"Off\"], defaultValue: \"1\" },\n  color: { type: ControlType.Color, title: \"Text colour\", defaultValue: \"#fbf8f1\" },\n  accent: { type: ControlType.Color, title: \"Hover and underline colour\", defaultValue: \"#e6ff55\" },\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 \"Distorted link hover\" 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 \"Distorted link hover\" element from the Enrichr Library: Big links whose letters and underline ripple like heat haze on hover, using an animated SVG turbulence displacement filter.\nPage: https://enrichr.dev/elements/distorted-link-hover.html\nMachine-readable spec: https://enrichr.dev/elements/distorted-link-hover.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-distorted-link-hover\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-distorted-link-hover\"), { ...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": "Links are normal anchors, so keyboard focus triggers the same ripple as hover and the colour and underline change give a clear focus state. The text is never replaced, only displaced visually. With reduced motion there is no filter at all: hover and focus just change the colour and draw the underline. Anchors that point to # are kept from jumping the page in demos.",
  "performance": "The animation loop runs only while at least one link is rippling and stops afterwards, and it pauses off screen. SVG filters repaint the filtered element on every change, so keep the number of links modest and the displacement strength moderate on low powered devices.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-dis\"><ul class=\"ef-dis__list\"></ul></div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-dis { container-type: inline-size; width: 100%; min-height: 16rem; display: flex; align-items: center; justify-content: center; padding: 1rem 0; box-sizing: border-box; }\n.ef-dis__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 0.1em; }\n.ef-dis__a { position: relative; display: inline-block; padding: 0.06em 0.14em; font-family: ui-sans-serif, system-ui, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif; font-size: 2rem; font-size: clamp(1.7rem, 12cqi, 3.8rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; color: var(--ef-dis-c, #fbf8f1); text-decoration: none; outline: none; transition: color 0.35s ease; }\n.ef-dis__a::after { content: \"\"; position: absolute; left: 0.14em; right: 0.14em; bottom: 0.03em; height: 0.085em; border-radius: 999px; background: var(--ef-dis-a, #e6ff55); transform: scaleX(0); transform-origin: left center; transition: transform 0.55s cubic-bezier(0.7, 0, 0.2, 1); }\n.ef-dis__a:hover, .ef-dis__a:focus-visible, .ef-dis__a.is-on { color: var(--ef-dis-a, #e6ff55); }\n.ef-dis__a:hover::after, .ef-dis__a:focus-visible::after, .ef-dis__a.is-on::after { transform: scaleX(1); }\n@media (prefers-reduced-motion: reduce) { .ef-dis__a, .ef-dis__a::after { transition: none; } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Distorted link hover: big links whose letters and underline ripple like heat haze on hover or focus.\r\n// Each link owns an SVG feTurbulence + feDisplacementMap filter that JS animates, then removes once the link is calm again.\r\n// mount(root, { items (comma separated), strength (max displacement in px for a 64px tall link, scaled with link size, 0-60), idle (1 = a link ripples by itself every few seconds, 0 = only on hover), color, accent (hover and underline colour), frequency (noise detail, 0.005-0.08) })\r\nfunction mount(root, o) {\r\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\r\n  var ul = root.querySelector(\".ef-dis__list\");\r\n  var NS = \"http://www.w3.org/2000/svg\", uid = Math.random().toString(36).slice(2, 8);\r\n  var svg = document.createElementNS(NS, \"svg\");\r\n  svg.setAttribute(\"aria-hidden\", \"true\"); svg.setAttribute(\"width\", \"0\"); svg.setAttribute(\"height\", \"0\");\r\n  svg.style.cssText = \"position:absolute;width:0;height:0;pointer-events:none\";\r\n  root.querySelector(\".ef-dis\").appendChild(svg);\r\n\r\n  var opts = {}, links = [], raf = 0, last = 0, clock = 0, visible = true, io = null, idleTimer = 0, idleI = 0;\r\n\r\n  function build() {\r\n    links.forEach(function (l) { l.a.removeEventListener(\"pointerenter\", l.on); l.a.removeEventListener(\"pointerleave\", l.off); l.a.removeEventListener(\"focus\", l.on); l.a.removeEventListener(\"blur\", l.off); l.a.removeEventListener(\"click\", l.click); });\r\n    ul.textContent = \"\"; svg.textContent = \"\"; links = [];\r\n    opts.items.split(\",\").map(function (s) { return s.trim(); }).filter(Boolean).forEach(function (label, i) {\r\n      var li = document.createElement(\"li\"), a = document.createElement(\"a\");\r\n      a.className = \"ef-dis__a\"; a.href = \"#\"; a.textContent = label; li.appendChild(a); ul.appendChild(li);\r\n      var fid = \"ef-dis-\" + uid + \"-\" + i;\r\n      var f = document.createElementNS(NS, \"filter\"), turb = document.createElementNS(NS, \"feTurbulence\"), disp = document.createElementNS(NS, \"feDisplacementMap\");\r\n      f.setAttribute(\"id\", fid); f.setAttribute(\"x\", \"-20%\"); f.setAttribute(\"y\", \"-60%\"); f.setAttribute(\"width\", \"140%\"); f.setAttribute(\"height\", \"220%\");\r\n      turb.setAttribute(\"type\", \"fractalNoise\"); turb.setAttribute(\"numOctaves\", \"1\"); turb.setAttribute(\"seed\", String(i * 7 + 3)); turb.setAttribute(\"result\", \"n\");\r\n      turb.setAttribute(\"baseFrequency\", \"0.012 0.04\");\r\n      disp.setAttribute(\"in\", \"SourceGraphic\"); disp.setAttribute(\"in2\", \"n\"); disp.setAttribute(\"scale\", \"0\");\r\n      disp.setAttribute(\"xChannelSelector\", \"R\"); disp.setAttribute(\"yChannelSelector\", \"G\");\r\n      f.appendChild(turb); f.appendChild(disp); svg.appendChild(f);\r\n      var l = { a: a, fid: fid, turb: turb, disp: disp, e: 0, hover: false, on: null, off: null, click: null, filtered: false };\r\n      l.on = function () { l.hover = true; l.e = Math.max(l.e, 1); kick(); };\r\n      l.off = function () { l.hover = false; kick(); };\r\n      l.click = function (ev) { if (a.getAttribute(\"href\") === \"#\") ev.preventDefault(); };\r\n      a.addEventListener(\"pointerenter\", l.on); a.addEventListener(\"pointerleave\", l.off);\r\n      a.addEventListener(\"focus\", l.on); a.addEventListener(\"blur\", l.off); a.addEventListener(\"click\", l.click);\r\n      links.push(l);\r\n    });\r\n  }\r\n  function kick() {\r\n    if (reduce || raf || !visible) return;\r\n    last = performance.now(); raf = requestAnimationFrame(tick);\r\n  }\r\n  function tick(t) {\r\n    raf = 0;\r\n    var dt = Math.min(0.05, (t - last) / 1000 || 0.016); last = t; clock += dt;\r\n    var str = Number(opts.strength), fr = Number(opts.frequency), busy = false;\r\n    links.forEach(function (l) {\r\n      var goal = l.hover ? 0.32 : 0;\r\n      l.e += (goal - l.e) * (1 - Math.exp(-dt * (l.hover ? 2.6 : 3.4)));\r\n      if (l.e < 0.004 && !l.hover) {\r\n        if (l.filtered) { l.a.style.filter = \"\"; l.disp.setAttribute(\"scale\", \"0\"); l.filtered = false; }\r\n        return;\r\n      }\r\n      busy = true;\r\n      if (!l.filtered) { l.a.style.filter = \"url(#\" + l.fid + \")\"; l.filtered = true; }\r\n      var w = 0.7 + 0.3 * Math.sin(clock * 5.1);\r\n      l.turb.setAttribute(\"baseFrequency\", (fr * 0.5 * (1 + 0.3 * Math.sin(clock * 1.7))).toFixed(4) + \" \" + (fr * 1.6 * (1 + 0.25 * Math.cos(clock * 1.3))).toFixed(4));\r\n      l.disp.setAttribute(\"scale\", (str * Math.min(1.3, Math.max(0.45, l.a.offsetHeight / 64)) * l.e * w).toFixed(2));\r\n    });\r\n    if (busy && visible) raf = requestAnimationFrame(tick);\r\n  }\r\n  function idle() {\r\n    clearTimeout(idleTimer); idleTimer = 0;\r\n    if (reduce || !Number(opts.idle) || !links.length || !visible) return;\r\n    idleTimer = setTimeout(function () {\r\n      var l = links[idleI++ % links.length];\r\n      if (!l.hover) l.e = Math.max(l.e, 0.8);\r\n      kick(); idle();\r\n    }, 2600);\r\n  }\r\n  function update(next) {\r\n    var prev = opts.items;\r\n    opts = Object.assign({ items: \"Work, Studio, Journal, About, Contact\", strength: 24, idle: 1, color: \"#fbf8f1\", accent: \"#e6ff55\", frequency: 0.025 }, opts, next || {});\r\n    root.querySelector(\".ef-dis\").style.setProperty(\"--ef-dis-c\", opts.color);\r\n    root.querySelector(\".ef-dis\").style.setProperty(\"--ef-dis-a\", opts.accent);\r\n    if (prev !== opts.items) build();\r\n    kick(); idle();\r\n  }\r\n  update(o);\r\n  if (\"IntersectionObserver\" in window && !reduce) {\r\n    io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; if (visible) { kick(); idle(); } else { cancelAnimationFrame(raf); raf = 0; clearTimeout(idleTimer); } });\r\n    io.observe(root);\r\n  }\r\n  return {\r\n    update: update,\r\n    destroy: function () {\r\n      cancelAnimationFrame(raf); raf = 0; clearTimeout(idleTimer);\r\n      if (io) io.disconnect();\r\n      links.forEach(function (l) { l.a.style.filter = \"\"; l.a.removeEventListener(\"pointerenter\", l.on); l.a.removeEventListener(\"pointerleave\", l.off); l.a.removeEventListener(\"focus\", l.on); l.a.removeEventListener(\"blur\", l.off); l.a.removeEventListener(\"click\", l.click); });\r\n      if (svg.parentNode) svg.parentNode.removeChild(svg);\r\n    }\r\n  };\r\n}"
  }
}