{
  "id": "unroll-image-scroll",
  "kind": "element",
  "title": "Unroll image on scroll",
  "summary": "A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.",
  "url": "https://enrichr.dev/elements/unroll-image-scroll.html",
  "section": "gallery",
  "techniques": [
    "scroll-driven",
    "reveal",
    "pointer-interaction"
  ],
  "stack": [
    "Vanilla JS",
    "Canvas 2D"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "tactile",
    "cinematic",
    "playful"
  ],
  "intents": [
    "image unroll animation",
    "paper scroll reveal",
    "unrolling poster on scroll",
    "roll out image effect",
    "rolled paper hover reveal"
  ],
  "status": "tested",
  "params": [
    {
      "key": "direction",
      "label": "Unrolls toward",
      "type": "select",
      "options": [
        [
          "right",
          "Right"
        ],
        [
          "left",
          "Left"
        ],
        [
          "down",
          "Down"
        ],
        [
          "up",
          "Up"
        ]
      ],
      "value": "right"
    },
    {
      "key": "radius",
      "label": "Core roll radius (px)",
      "type": "range",
      "min": 8,
      "max": 60,
      "step": 2,
      "value": 22
    },
    {
      "key": "trigger",
      "label": "Triggered by",
      "type": "select",
      "options": [
        [
          "scroll",
          "Scroll"
        ],
        [
          "hover",
          "Hover or focus"
        ]
      ],
      "value": "scroll"
    },
    {
      "key": "manual",
      "label": "Fixed unrolled % (0 is live)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 5,
      "value": 0
    },
    {
      "key": "colorA",
      "label": "Poster colour",
      "type": "color",
      "value": "#005236"
    },
    {
      "key": "colorB",
      "label": "Accent 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 \"Unroll image on scroll\" element to this project.\n\nThis is the \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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/unroll-image-scroll.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 \"Unroll image on scroll\" 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 \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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 \"Unroll image on scroll\" element to this codebase.\n\nThis is the \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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-unroll-image-scroll.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Unroll image on scroll 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 \"Unroll image on scroll\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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- unroll-image-scroll.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 \"./unroll-image-scroll\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function UnrollImageScroll(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 \"Unroll image on scroll\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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- unroll-image-scroll.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/UnrollImageScroll.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./unroll-image-scroll\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function UnrollImageScroll(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 \"Unroll image on scroll\" element.\n\nThis is the \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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), unroll-image-scroll.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 \"Unroll image on scroll\" element. No packages, no server code.\n\nThis is the \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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 unroll-image-scroll.js and then main.js), style.css (the CSS below), unroll-image-scroll.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 \"Unroll image on scroll\" 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 \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.json\n\nWhat it does: The sheet is treated as a strip of paper with a fixed end and a loose end. The unrolled part is drawn flat. The rest is wound into a spiral whose radius shrinks from the outer turn down to the core radius, which is the curve you get from paper of fixed thickness. The spiral is walked in small angle steps, and each step becomes one thin vertical strip: strips facing the viewer show a slice of the picture squeezed by the cosine of the angle and shaded, and strips facing away show the cream back of the paper. The strips are sorted by depth and drawn back to front, with a slight size increase for the ones nearer the viewer. A shared transform lets the same code unroll in any of four directions.\nAccessibility: The canvas has a text label, and in hover mode the block is focusable so keyboard users can unroll it by focusing it. The picture is decorative. With prefers-reduced-motion the poster is shown fully unrolled and nothing animates.\n\nTunable settings:\n- Unrolls toward: select (Right / Left / Down / Up), default right\n- Core roll radius (px): range 8 to 60, step 2, default 22\n- Triggered by: select (Scroll / Hover or focus), default scroll\n- Fixed unrolled % (0 is live): range 0 to 100, step 5, default 0\n- Poster colour: color, default #005236\n- Accent 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/unroll-image-scroll.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 \"Unroll image on scroll\" 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 \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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 UnrollImageScroll.\n2. Paste the JavaScript below into a separate code file named unroll-image-scroll.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 \"./unroll-image-scroll\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function UnrollImageScroll(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(UnrollImageScroll, {\n  direction: { type: ControlType.Enum, title: \"Unrolls toward\", options: [\"right\",\"left\",\"down\",\"up\"], optionTitles: [\"Right\",\"Left\",\"Down\",\"Up\"], defaultValue: \"right\" },\n  radius: { type: ControlType.Number, title: \"Core roll radius\", min: 8, max: 60, step: 2, defaultValue: 22 },\n  trigger: { type: ControlType.Enum, title: \"Triggered by\", options: [\"scroll\",\"hover\"], optionTitles: [\"Scroll\",\"Hover or focus\"], defaultValue: \"scroll\" },\n  manual: { type: ControlType.Number, title: \"Fixed unrolled %\", min: 0, max: 100, step: 5, defaultValue: 0 },\n  colorA: { type: ControlType.Color, title: \"Poster colour\", defaultValue: \"#005236\" },\n  colorB: { type: ControlType.Color, title: \"Accent 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 \"Unroll image on scroll\" 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 \"Unroll image on scroll\" element from the Enrichr Library: A poster that unrolls like a sheet of paper from a spiral roll as you scroll or hover.\nPage: https://enrichr.dev/elements/unroll-image-scroll.html\nMachine-readable spec: https://enrichr.dev/elements/unroll-image-scroll.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-unroll-image-scroll\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-unroll-image-scroll\"), { ...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 canvas has a text label, and in hover mode the block is focusable so keyboard users can unroll it by focusing it. The picture is decorative. With prefers-reduced-motion the poster is shown fully unrolled and nothing animates.",
  "performance": "A single 2D canvas redrawn only while the unrolled amount is changing, with a few hundred small rectangles and image slices per frame at most. The canvas resolution is capped at 2x and drawing pauses off screen.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-unr\"><canvas class=\"ef-unr__c\" role=\"img\" aria-label=\"A poster that unrolls like a sheet of paper\"></canvas></div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-unr { position: relative; width: 100%; min-height: 20rem; overflow: hidden; background: var(--ef-unr-bg, #e9e3d3); background-image: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.55), rgba(0, 0, 0, 0.08)); }\n.ef-unr__c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }\n.ef-unr--hover { cursor: pointer; }\n.ef-unr:focus-visible { outline: 3px solid #005236; outline-offset: -3px; }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Unroll image: a poster drawn on a canvas that unrolls like a sheet of paper. The loose end of the sheet curls up around a\n// spiral roll; the flat part is drawn as thin strips of the picture and the roll is the same sheet wound on a shrinking\n// radius, back side showing, sorted by depth. It unrolls with scroll (or on hover and focus) and rolls up again in reverse.\n// Everything is drawn in code, so there is no image file. Reduced motion shows the poster fully unrolled.\n// mount(root, { direction (\"right\" | \"left\" | \"down\" | \"up\": the way it unrolls), radius (core radius px), trigger (\"scroll\" | \"hover\"),\n//               manual (0 = live, 1-100 = fixed unrolled %), colorA (poster green), colorB (accent) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var box = root.querySelector(\".ef-unr\");\n  var canvas = root.querySelector(\".ef-unr__c\");\n  var ctx = canvas.getContext(\"2d\");\n  var tex = document.createElement(\"canvas\"), src = document.createElement(\"canvas\");\n  var opts = {}, raf = 0, visible = true, io = null, ro = null;\n  var u = 0, target = 0, hov = false, lastDrawn = -1, dpr = 1, lenS = 1, brdB = 1, M = null;\n  var PAPER = [236, 228, 208];\n\n  function colorOk(v, fb) { return /^(#[0-9a-f]{3,8}|[a-z]{3,20}|rgba?\\([\\d\\s.,%]+\\))$/i.test(String(v)) ? String(v) : fb; }\n  function art(c, w, h) {\n    var g = c.createLinearGradient(0, 0, 0, h);\n    g.addColorStop(0, \"#0c1e18\"); g.addColorStop(1, opts.colorA);\n    c.fillStyle = g; c.fillRect(0, 0, w, h);\n    var u0 = Math.min(w, h) / 100;\n    c.strokeStyle = \"rgba(251,248,241,0.16)\"; c.lineWidth = Math.max(1, u0 * 0.25);\n    for (var i = 1; i <= 5; i++) { c.beginPath(); c.arc(w * 0.72, h * 0.34, u0 * (14 + i * 9), 0, 6.2832); c.stroke(); }\n    c.fillStyle = opts.colorB; c.beginPath(); c.arc(w * 0.72, h * 0.34, u0 * 13, 0, 6.2832); c.fill();\n    var layers = [[\"rgba(251,248,241,0.10)\", 0.62, 0.05, 1.7], [\"rgba(251,248,241,0.16)\", 0.72, 0.06, 2.6], [\"#0c1e18\", 0.84, 0.05, 3.9]];\n    layers.forEach(function (L, k) {\n      c.fillStyle = L[0]; c.beginPath(); c.moveTo(0, h);\n      for (var x = 0; x <= w; x += w / 60) c.lineTo(x, h * L[1] - Math.abs(Math.sin(x / w * 5 + L[3])) * h * L[2] * 2 - Math.sin(x / w * 11 + k) * h * 0.012);\n      c.lineTo(w, h); c.closePath(); c.fill();\n    });\n    c.fillStyle = \"#fbf8f1\"; c.textBaseline = \"alphabetic\";\n    c.font = \"900 \" + (u0 * 17).toFixed(1) + \"px Helvetica Neue, Arial, Segoe UI, system-ui, sans-serif\";\n    c.fillText(\"UNROLL\", w * 0.07, h * 0.19 + u0 * 8);\n    c.fillStyle = opts.colorB; c.fillRect(w * 0.07, h * 0.19 + u0 * 12, u0 * 14, Math.max(2, u0 * 1.2));\n  }\n  function build() {\n    var r = box.getBoundingClientRect();\n    dpr = Math.min(2, window.devicePixelRatio || 1);\n    var w = Math.max(40, Math.round(r.width * dpr)), h = Math.max(40, Math.round(r.height * dpr));\n    canvas.width = w; canvas.height = h;\n    tex.width = w; tex.height = h; art(tex.getContext(\"2d\"), w, h);\n    var d = opts.direction;\n    var m = d === \"left\" ? [-1, 0, 0, 1, w, 0] : d === \"down\" ? [0, 1, 1, 0, 0, 0] : d === \"up\" ? [0, -1, 1, 0, 0, h] : [1, 0, 0, 1, 0, 0];\n    var vert = d === \"down\" || d === \"up\";\n    lenS = vert ? h : w; brdB = vert ? w : h;\n    M = m;\n    src.width = lenS; src.height = brdB;\n    var sc = src.getContext(\"2d\");\n    var inv = new DOMMatrix(m).inverse();\n    sc.setTransform(inv.a, inv.b, inv.c, inv.d, inv.e, inv.f);\n    sc.drawImage(tex, 0, 0);\n    lastDrawn = -1;\n    draw();\n  }\n  function draw() {\n    if (Math.abs(u - lastDrawn) < 0.0003) return;\n    lastDrawn = u;\n    var cw = canvas.width, ch = canvas.height;\n    ctx.setTransform(1, 0, 0, 1, 0, 0);\n    ctx.clearRect(0, 0, cw, ch);\n    ctx.setTransform(M[0], M[1], M[2], M[3], M[4], M[5]);\n    var S = lenS, B = brdB, R0 = Math.max(3, opts.radius) * dpr, k = (1.7 * dpr) / 6.2832;\n    var L = u * S, rem = S - L;\n    var Rout = Math.sqrt(R0 * R0 + 2 * k * rem), thMax = (Rout - R0) / k;\n    var Rout0 = Math.sqrt(R0 * R0 + 2 * k * S);\n    var shift = Math.max(0, Rout0 - L);\n    if (L > 0.5) {\n      // soft shadow cast by the roll onto the flat sheet\n      ctx.drawImage(src, 0, 0, L, B, shift, 0, L, B);\n      if (rem > 1) {\n        var sg = ctx.createLinearGradient(L + shift - Rout * 3, 0, L + shift, 0);\n        sg.addColorStop(0, \"rgba(0,0,0,0)\"); sg.addColorStop(1, \"rgba(0,0,0,0.30)\");\n        ctx.fillStyle = sg; ctx.fillRect(Math.max(shift, L + shift - Rout * 3), 0, Math.min(L, Rout * 3), B);\n      }\n    }\n    if (rem <= 1) return;\n    var strips = [], x = L + shift, z = 0, step = 0.09, n = Math.max(1, Math.ceil(thMax / step)), prevTh = 0, prevS = 0;\n    for (var j = 1; j <= n; j++) {\n      var th = Math.min(thMax, j * step);\n      var s = Rout * th - k * th * th / 2, ds = s - prevS, mid = (th + prevTh) / 2;\n      var dx = Math.cos(mid) * ds, dz = Math.sin(mid) * ds;\n      strips.push({ x: x, dx: dx, z: z + dz / 2, s0: L + prevS, ds: ds, c: Math.cos(mid) });\n      x += dx; z += dz; prevS = s; prevTh = th;\n    }\n    strips.sort(function (a, b) { return a.z - b.z; });\n    var D = 1100 * dpr;\n    strips.forEach(function (t) {\n      var w = Math.abs(t.dx);\n      if (w < 0.25) return;\n      var sc = 1 / (1 - Math.min(0.5, t.z / D)), h = B * sc, y = (B - h) / 2, x0 = t.dx > 0 ? t.x : t.x + t.dx;\n      if (t.c > 0) {\n        ctx.drawImage(src, t.s0, 0, t.ds, B, x0, y, Math.max(w, 0.7), h);\n        ctx.fillStyle = \"rgba(0,0,0,\" + (0.55 * (1 - t.c)).toFixed(3) + \")\";\n        ctx.fillRect(x0, y, Math.max(w, 0.7), h);\n      } else {\n        var f = 0.5 + 0.5 * Math.abs(t.c);\n        ctx.fillStyle = \"rgb(\" + Math.round(PAPER[0] * f) + \",\" + Math.round(PAPER[1] * f) + \",\" + Math.round(PAPER[2] * f) + \")\";\n        ctx.fillRect(x0, y, Math.max(w, 0.7), h);\n      }\n    });\n  }\n  function scrollTarget() {\n    var r = box.getBoundingClientRect(), vh = window.innerHeight || 800;\n    return Math.min(1, Math.max(0, (vh * 0.95 - r.top) / (vh * 0.6)));\n  }\n  function want() {\n    if (reduce) return 1;\n    if (opts.manual > 0) return opts.manual / 100;\n    return opts.trigger === \"hover\" ? (hov ? 1 : 0) : scrollTarget();\n  }\n  function tick() {\n    raf = requestAnimationFrame(tick);\n    if (!visible) return;\n    target = want();\n    u += (target - u) * 0.12;\n    if (Math.abs(target - u) < 0.0015) u = target;\n    draw();\n  }\n  function on() { hov = true; }\n  function off() { hov = false; }\n  function update(next) {\n    var prevDir = opts.direction;\n    opts = Object.assign({ direction: \"right\", radius: 22, trigger: \"scroll\", manual: 0, colorA: \"#005236\", colorB: \"#e6ff55\" }, opts, next || {});\n    opts.radius = Number(opts.radius); opts.manual = Number(opts.manual);\n    opts.colorA = colorOk(opts.colorA, \"#005236\"); opts.colorB = colorOk(opts.colorB, \"#e6ff55\");\n    if ([\"right\", \"left\", \"down\", \"up\"].indexOf(opts.direction) < 0) opts.direction = \"right\";\n    var hover = opts.trigger === \"hover\";\n    box.classList.toggle(\"ef-unr--hover\", hover);\n    if (hover && !reduce) { box.tabIndex = 0; box.setAttribute(\"role\", \"group\"); box.setAttribute(\"aria-label\", \"Poster that unrolls on hover or focus\"); }\n    else { box.removeAttribute(\"tabindex\"); box.removeAttribute(\"role\"); box.removeAttribute(\"aria-label\"); }\n    u = target = want();\n    build();\n  }\n  update(o);\n  box.addEventListener(\"pointerenter\", on); box.addEventListener(\"pointerleave\", off);\n  box.addEventListener(\"focus\", on); box.addEventListener(\"blur\", off);\n  if (\"ResizeObserver\" in window) { ro = new ResizeObserver(function () { build(); }); ro.observe(box); }\n  if (!reduce) {\n    if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(box); }\n    raf = requestAnimationFrame(tick);\n  }\n  return { update: update, destroy: function () {\n    cancelAnimationFrame(raf); if (io) io.disconnect(); if (ro) ro.disconnect();\n    box.removeEventListener(\"pointerenter\", on); box.removeEventListener(\"pointerleave\", off);\n    box.removeEventListener(\"focus\", on); box.removeEventListener(\"blur\", off);\n  } };\n}"
  }
}