Skip to content

Herk Edit Kit by Nate Herk: edit videos, reels, and YouTube Shorts with Codex or Claude Code. 15 skills, transcript-driven cuts, storytelling, 406 motion-graphics cards, and HyperFrames templates.

4.8 KB
Raw Blame
<template id="ambient-bg-template">
  <div
    data-composition-id="ambient-bg"
    data-start="0"
    data-width="1080"
    data-height="1920"
    data-duration="18.84"
  >
    <div class="amb-root">
      <!-- Base radial gradient gives the navy some center-lift shape -->
      <div class="amb-base"></div>

      <!-- Grid mesh, low-opacity, slowly drifts for parallax feel -->
      <div class="amb-grid" id="amb-grid"></div>

      <!-- Drifting particle dots -->
      <div class="amb-particles">
        <div class="amb-dot" style="left: 12%; top: 18%;"></div>
        <div class="amb-dot" style="left: 82%; top: 9%;"></div>
        <div class="amb-dot" style="left: 40%; top: 32%;"></div>
        <div class="amb-dot" style="left: 91%; top: 52%;"></div>
        <div class="amb-dot" style="left: 8%; top: 68%;"></div>
        <div class="amb-dot" style="left: 62%; top: 78%;"></div>
        <div class="amb-dot" style="left: 24%; top: 88%;"></div>
        <div class="amb-dot" style="left: 74%; top: 28%;"></div>
      </div>

      <!-- Edge vignette so corners darken into the bezel -->
      <div class="amb-vignette"></div>
    </div>

    <style>
      [data-composition-id="ambient-bg"] {
        position: absolute;
        inset: 0;
        pointer-events: none;
      }
      [data-composition-id="ambient-bg"] .amb-root {
        position: absolute;
        inset: 0;
        overflow: hidden;
      }
      [data-composition-id="ambient-bg"] .amb-base {
        position: absolute;
        inset: 0;
        background:
          radial-gradient(
            ellipse 80% 60% at 50% 28%,
            #0f2033 0%,
            #0a1828 45%,
            #07121c 80%,
            #050b13 100%
          );
      }
      [data-composition-id="ambient-bg"] .amb-grid {
        position: absolute;
        inset: -40px;
        background-image:
          linear-gradient(rgba(55, 189, 248, 0.045) 1px, transparent 1px),
          linear-gradient(90deg, rgba(55, 189, 248, 0.045) 1px, transparent 1px);
        background-size: 80px 80px;
        opacity: 0.75;
        will-change: transform;
      }
      [data-composition-id="ambient-bg"] .amb-particles {
        position: absolute;
        inset: 0;
      }
      [data-composition-id="ambient-bg"] .amb-dot {
        position: absolute;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #37bdf8;
        box-shadow: 0 0 12px rgba(55, 189, 248, 0.6);
        opacity: 0.55;
        will-change: transform, opacity;
      }
      [data-composition-id="ambient-bg"] .amb-vignette {
        position: absolute;
        inset: 0;
        background: radial-gradient(
          ellipse 100% 80% at 50% 50%,
          transparent 55%,
          rgba(5, 11, 19, 0.45) 85%,
          rgba(5, 11, 19, 0.8) 100%
        );
      }
    </style>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
    <script>
      (function () {
        const tl = gsap.timeline({ paused: true });
        const scope = '[data-composition-id="ambient-bg"] ';
        const TOTAL = 18.84;

        // Slow grid drift — 80px cycle. Deterministic finite repeat so the
        // capture engine can seek to exact frames.
        const GRID_CYCLE = 12;
        tl.to(
          scope + "#amb-grid",
          {
            x: -80,
            y: -80,
            duration: GRID_CYCLE,
            ease: "none",
            repeat: Math.max(Math.floor(TOTAL / GRID_CYCLE) - 1, 0),
          },
          0,
        );

        // Particle drift — each dot moves in a loose orbit at a unique phase.
        const dots = document.querySelectorAll(scope + ".amb-dot");
        dots.forEach(function (dot, i) {
          const dx = 40 + (i % 3) * 14;
          const dy = 30 + ((i + 1) % 3) * 12;
          const dur = 8 + (i % 4) * 1.2;
          // yoyo + finite repeats so full cycles (out + back) stay within TOTAL.
          const cycles = Math.max(Math.floor(TOTAL / (dur * 2)), 1);
          const repeatCount = cycles * 2 - 1;
          tl.to(
            dot,
            {
              x: dx,
              y: -dy,
              duration: dur,
              ease: "sine.inOut",
              yoyo: true,
              repeat: repeatCount,
            },
            0,
          );
          const opDur = dur * 0.6;
          const opCycles = Math.max(Math.floor(TOTAL / (opDur * 2)), 1);
          tl.to(
            dot,
            {
              opacity: 0.85,
              duration: opDur,
              ease: "sine.inOut",
              yoyo: true,
              repeat: opCycles * 2 - 1,
            },
            0,
          );
        });

        // Pad to composition duration.
        tl.set({}, {}, TOTAL);

        window.__timelines = window.__timelines || {};
        window.__timelines["ambient-bg"] = tl;
      })();
    </script>
  </div>
</template>