{
  "id": "scroll-spring-heading",
  "kind": "element",
  "title": "Scroll spring heading",
  "summary": "An oversized heading slides sideways with scroll progress through a spring, lagging and settling.",
  "url": "https://enrichr.dev/elements/scroll-spring-heading.html",
  "section": "text",
  "techniques": [
    "scroll-driven",
    "text-animation"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "bold",
    "editorial"
  ],
  "intents": [
    "oversized heading scroll",
    "horizontal text on scroll",
    "spring scroll text",
    "big type parallax",
    "kinetic heading"
  ],
  "status": "tested",
  "params": [
    {
      "key": "text",
      "label": "Heading",
      "type": "text",
      "value": "Keep moving"
    },
    {
      "key": "distance",
      "label": "Travel each side (px)",
      "type": "range",
      "min": 0,
      "max": 600,
      "step": 10,
      "value": 220
    },
    {
      "key": "stiffness",
      "label": "Stiffness",
      "type": "range",
      "min": 0.01,
      "max": 0.3,
      "step": 0.01,
      "value": 0.06
    },
    {
      "key": "damping",
      "label": "Damping",
      "type": "range",
      "min": 0.5,
      "max": 0.98,
      "step": 0.01,
      "value": 0.82
    },
    {
      "key": "manual",
      "label": "Fixed progress % (0 follows scroll)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 5,
      "value": 0
    },
    {
      "key": "color",
      "label": "Text colour",
      "type": "color",
      "value": "#ffffff"
    }
  ],
  "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 \"Scroll spring heading\" element to this project.\n\nThis is the \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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/scroll-spring-heading.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 \"Scroll spring heading\" 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 \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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 \"Scroll spring heading\" element to this codebase.\n\nThis is the \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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-scroll-spring-heading.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Scroll spring heading 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 \"Scroll spring heading\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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- scroll-spring-heading.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 \"./scroll-spring-heading\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ScrollSpringHeading(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 \"Scroll spring heading\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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- scroll-spring-heading.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/ScrollSpringHeading.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./scroll-spring-heading\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ScrollSpringHeading(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 \"Scroll spring heading\" element.\n\nThis is the \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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), scroll-spring-heading.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 \"Scroll spring heading\" element. No packages, no server code.\n\nThis is the \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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 scroll-spring-heading.js and then main.js), style.css (the CSS below), scroll-spring-heading.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 \"Scroll spring heading\" 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 \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.json\n\nWhat it does: Scroll progress is the element's position as it travels through the viewport, from 0 to 1. That maps to a target offset from minus to plus the travel distance. Each frame a small spring pulls the current offset toward the target: velocity gains stiffness times the gap, loses a share to damping, and moves the heading. Higher stiffness snaps; lower damping overshoots.\nAccessibility: The heading stays real text and the movement is decorative. With reduced motion it does not move. The heading can run partly out of view on narrow screens, so keep the travel small there and do not depend on seeing every letter.\n\nTunable settings:\n- Heading: text, default Keep moving\n- Travel each side (px): range 0 to 600, step 10, default 220\n- Stiffness: range 0.01 to 0.3, step 0.01, default 0.06\n- Damping: range 0.5 to 0.98, step 0.01, default 0.82\n- Fixed progress % (0 follows scroll): range 0 to 100, step 5, default 0\n- Text colour: color, default #ffffff\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/scroll-spring-heading.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 \"Scroll spring heading\" 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 \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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 ScrollSpringHeading.\n2. Paste the JavaScript below into a separate code file named scroll-spring-heading.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 \"./scroll-spring-heading\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ScrollSpringHeading(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(ScrollSpringHeading, {\n  text: { type: ControlType.String, title: \"Heading\", defaultValue: \"Keep moving\" },\n  distance: { type: ControlType.Number, title: \"Travel each side\", min: 0, max: 600, step: 10, defaultValue: 220 },\n  stiffness: { type: ControlType.Number, title: \"Stiffness\", min: 0.01, max: 0.3, step: 0.01, defaultValue: 0.06 },\n  damping: { type: ControlType.Number, title: \"Damping\", min: 0.5, max: 0.98, step: 0.01, defaultValue: 0.82 },\n  manual: { type: ControlType.Number, title: \"Fixed progress %\", min: 0, max: 100, step: 5, defaultValue: 0 },\n  color: { type: ControlType.Color, title: \"Text colour\", defaultValue: \"#ffffff\" },\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 \"Scroll spring heading\" 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 \"Scroll spring heading\" element from the Enrichr Library: An oversized heading slides sideways with scroll progress through a spring, lagging and settling.\nPage: https://enrichr.dev/elements/scroll-spring-heading.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-spring-heading.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-scroll-spring-heading\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-scroll-spring-heading\"), { ...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": "The heading stays real text and the movement is decorative. With reduced motion it does not move. The heading can run partly out of view on narrow screens, so keep the travel small there and do not depend on seeing every letter.",
  "performance": "One bounding-rect read and one transform write per frame while on screen; paused off screen. No layout work.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-spring\"><div class=\"ef-spring__h\"></div></div>",
    "css": ".ef-spring { overflow: hidden; }\r\n.ef-spring__h { display: inline-block; white-space: nowrap; font-size: clamp(3rem, 14vw, 9rem); font-weight: 800; line-height: 1; letter-spacing: -0.04em; will-change: transform; }\r\n@media (prefers-reduced-motion: reduce) { .ef-spring__h { transform: none !important; } }",
    "js": "// Scroll spring heading: an oversized heading slides sideways as the page scrolls, following scroll progress through a spring,\r\n// so it lags behind, overshoots slightly and settles.\r\n// mount(root, { text, distance (px each side), stiffness (0.01-0.3), damping (0.5-0.98), manual (0 = follow scroll, 1-100 = fixed progress %), color })\r\nfunction mount(root, o) {\r\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\r\n  var wrap = root.querySelector(\".ef-spring\");\r\n  var h = root.querySelector(\".ef-spring__h\");\r\n  var opts = {}, raf = 0, pos = 0, vel = 0, visible = true, io = null;\r\n\r\n  function progress() {\r\n    if (opts.manual > 0) return opts.manual / 100;\r\n    var r = wrap.getBoundingClientRect(), vh = window.innerHeight || 800;\r\n    return Math.min(1, Math.max(0, (vh - r.top) / (vh + r.height)));\r\n  }\r\n  function tick() {\r\n    raf = requestAnimationFrame(tick);\r\n    if (!visible) return;\r\n    var target = (progress() - 0.5) * 2 * opts.distance;\r\n    vel = (vel + (target - pos) * opts.stiffness) * opts.damping;\r\n    pos += vel;\r\n    h.style.transform = \"translate3d(\" + pos.toFixed(1) + \"px,0,0)\";\r\n  }\r\n  function update(next) {\r\n    opts = Object.assign({ text: \"Keep moving\", distance: 220, stiffness: 0.06, damping: 0.82, manual: 0, color: \"#ffffff\" }, opts, next || {});\r\n    h.textContent = opts.text;\r\n    h.style.color = opts.color;\r\n    root.setAttribute(\"aria-label\", opts.text);\r\n  }\r\n  update(o);\r\n  if (!reduce) {\r\n    if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(wrap); }\r\n    raf = requestAnimationFrame(tick);\r\n  }\r\n  return { update: update, destroy: function () { cancelAnimationFrame(raf); if (io) io.disconnect(); } };\r\n}"
  }
}