Skip to content

Write HTML. Render video. Built for agents.

7.6 KB
Raw Blame
{"html":"<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=1920, height=1080\" />\n    <title>Pendulum Swing - Demo</title>\n    <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js\"></script>\n    <style>\n      * {\n        box-sizing: border-box;\n      }\n      html,\n      body {\n        margin: 0;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n      }\n      #demo {\n        position: relative;\n        width: 1920px;\n        height: 1080px;\n        display: grid;\n        place-items: center;\n        background: #f7f7f8;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .demo-frame {\n        display: flex;\n        flex-direction: column;\n        align-items: center;\n        gap: 40px;\n        /* ponytail: scale on non-GSAP wrapper — safe, GSAP only animates\n           --hf-swing-angle on the pendulum root below. */\n        transform: scale(1.4);\n        transform-origin: center center;\n      }\n      /* The hook the sign hangs from, drawn above the pivot for context. */\n      .swing-rig {\n        position: relative;\n        display: flex;\n        flex-direction: column;\n        align-items: center;\n      }\n      .swing-hook {\n        width: 18px;\n        height: 18px;\n        border-radius: 50%;\n        background: #a1a1aa;\n        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);\n      }\n      /* Pinned to the frame bottom, clear of the sign at its widest swing. */\n      .swing-label {\n        position: absolute;\n        bottom: 160px;\n        left: 50%;\n        transform: translateX(-50%);\n        font-size: 11px;\n        font-weight: 500;\n        letter-spacing: 0.08em;\n        text-transform: uppercase;\n        color: #71717a;\n      }\n      .hf-catalog-pendulum-swing {\n        display: inline-block;\n        transform-origin: var(--hf-swing-origin, 50% 0%);\n        transform: rotate(\n          calc(var(--hf-swing-angle, 0) * var(--hf-swing-dir, 1) * var(--hf-swing-max, 34deg))\n        );\n      }\n      .hf-catalog-pendulum-swing__body {\n        display: inline-block;\n        padding: 22px 40px;\n        border-radius: 14px;\n        background: var(--hf-swing-bg, #18181b);\n        color: var(--hf-swing-fg, #fafafa);\n        font-family: Inter, system-ui, sans-serif;\n        font-weight: 800;\n        font-size: 54px;\n        letter-spacing: -0.02em;\n        white-space: nowrap;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"demo\"\n      data-composition-id=\"pendulum-swing-demo\"\n      data-start=\"0\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n      data-duration=\"5\"\n    >\n      <div class=\"swing-label\">Pendulum Swing</div>\n      <div class=\"demo-frame\">\n        <div class=\"swing-rig\">\n          <div class=\"swing-hook\"></div>\n          <div\n            class=\"hf-catalog-pendulum-swing\"\n            data-composition-variables='[\n    { \"id\": \"pivot\", \"type\": \"enum\", \"role\": \"layout\", \"label\": \"Pivot\", \"description\": \"Where the content hangs from. The swing rotates about this point, so the top edge stays pinned.\", \"default\": \"top-center\", \"options\": [{ \"value\": \"top-center\", \"label\": \"Top center\" }, { \"value\": \"top-left\", \"label\": \"Top left\" }, { \"value\": \"top-right\", \"label\": \"Top right\" }] },\n    { \"id\": \"amplitude\", \"type\": \"enum\", \"role\": \"motion\", \"label\": \"Amplitude\", \"description\": \"How far the first swing reaches before it settles. Every later swing scales with it, so the pendulum still comes to rest upright.\", \"default\": \"standard\", \"options\": [{ \"value\": \"gentle\", \"label\": \"Gentle\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"wide\", \"label\": \"Wide\" }] },\n    { \"id\": \"direction\", \"type\": \"enum\", \"role\": \"motion\", \"label\": \"Direction\", \"description\": \"Which side the pendulum swings in from: right lifts the first swing clockwise, left mirrors it.\", \"default\": \"right\", \"options\": [{ \"value\": \"right\", \"label\": \"Right\" }, { \"value\": \"left\", \"label\": \"Left\" }] },\n    { \"id\": \"tone\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Tone\", \"description\": \"Content colour: ink for light frames, paper for dark ones, accent rides --brand.\", \"default\": \"ink\", \"options\": [{ \"value\": \"ink\", \"label\": \"Ink\" }, { \"value\": \"paper\", \"label\": \"Paper\" }, { \"value\": \"accent\", \"label\": \"Accent\" }] }\n  ]'\n          >\n            <span class=\"hf-catalog-pendulum-swing__body\">Hanging&nbsp;Sign</span>\n          </div>\n        </div>\n      </div>\n      <script>\n        (function () {\n          \"use strict\";\n\n          var vars =\n            window.__hyperframes && window.__hyperframes.getVariables\n              ? window.__hyperframes.getVariables()\n              : {};\n\n          // Unrecognised overrides return to their declared defaults.\n          function pick(table, value, fallback) {\n            return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;\n          }\n\n          var pivots = {\n            \"top-center\": \"50% 0%\",\n            \"top-left\": \"0% 0%\",\n            \"top-right\": \"100% 0%\",\n          };\n          var amplitudes = { gentle: \"18deg\", standard: \"34deg\", wide: \"52deg\" };\n          var directions = { right: 1, left: -1 };\n          // Each tone is a fill/text pair so the sign keeps AA contrast.\n          var tones = {\n            ink: { bg: \"#18181b\", fg: \"#fafafa\" },\n            paper: { bg: \"#fafafa\", fg: \"#18181b\" },\n            accent: { bg: \"var(--brand, #34d399)\", fg: \"#0b0b0c\" },\n          };\n\n          var origin = pivots[pick(pivots, vars.pivot, \"top-center\")];\n          var maxAngle = amplitudes[pick(amplitudes, vars.amplitude, \"standard\")];\n          var dir = directions[pick(directions, vars.direction, \"right\")];\n          var tone = tones[pick(tones, vars.tone, \"ink\")];\n\n          var roots = document.querySelectorAll(\".hf-catalog-pendulum-swing\");\n          for (var i = 0; i < roots.length; i += 1) {\n            var root = roots[i];\n            root.style.setProperty(\"--hf-swing-origin\", origin);\n            root.style.setProperty(\"--hf-swing-max\", maxAngle);\n            root.style.setProperty(\"--hf-swing-dir\", String(dir));\n            root.style.setProperty(\"--hf-swing-bg\", tone.bg);\n            root.style.setProperty(\"--hf-swing-fg\", tone.fg);\n          }\n        })();\n      </script>\n      <script>\n        const tl = gsap.timeline({ paused: true });\n        const startTime = 0.4;\n        // A pendulum does not snap upright in a single overshoot; it swings\n        // through the rest point several times, each pass smaller, until\n        // friction stills it. This ease is that motion: a cosine (the swings)\n        // inside an exponential decay (the damping). It is normalised so the\n        // tween still lands exactly upright (angle 0) at the end, and rotation\n        // stays sub-pixel under the seek-by-frame capture engine.\n        const swingSettle = (p) => 1 - Math.exp(-2.3 * p) * Math.cos(3.5 * Math.PI * p);\n        tl.fromTo(\n          \".hf-catalog-pendulum-swing\",\n          { \"--hf-swing-angle\": 1 },\n          {\n            \"--hf-swing-angle\": 0,\n            duration: 2.9,\n            ease: swingSettle,\n          },\n          startTime,\n        );\n        tl.set({}, {}, 5);\n        window.__timelines = window.__timelines || {};\n        window.__timelines[\"pendulum-swing-demo\"] = tl;\n      </script>\n    </div>\n  </body>\n</html>\n"}