Skip to content

Packs / web-development-public

motion-background

Three drop-in motion backgrounds behind real content (CSS gradient mesh, WebGL fbm-noise shader with fallback and capped DPR, seamless video loop) that pause off-screen and in hidden tabs, stop under reduced motion and share one Pause motion control.

Install

logicpacks pack use web-development-public/motion-background
get_pack web-development-public/motion-background

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: static-local
  • Checks: 1 in outcome/checks.yaml
  • Code: _shots/shot-1280-rm.png_shots/shot-1280.png_shots/shot-390-rm.png_shots/shot-390.pngbackgrounds.jsindex.htmlmedia/loop-poster.jpgmedia/loop.mp4media/loop.webmstyle.css
  • Tools: python3, playwright-python, chromium, ffmpeg (optional)

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

Give a section mood with motion that costs little: no layout jank, no battery drain off-screen, readable text on top, and an off switch. Pick the cheapest variant that achieves the look.

Steps

  1. Choose a variant:
    • CSS mesh (.mesh): no JS, transform-only keyframes, blur on the container. Default choice.
    • WebGL shader (#shader-canvas): when you need organic flow; renders at 0.75x size with DPR capped at 1.5.
    • Video loop ([data-bg-video]): when you have footage (e.g. a NovaMotion background loop, downloaded and re-encoded to WebM + MP4, <= 3 MB).
  2. Copy the section markup, the matching CSS block and backgrounds.js (each part is independent; delete the parts you do not use).
  3. Content sits above the background (isolation: isolate on the section, background at z-index: -1/-2, scrim for video).
  4. Keep the lifecycle: IntersectionObserver marks sections is-offscreen; shader rAF and video playback only run while visible, tab visible, and motion is on. The shader always draws one still frame so it never shows blank.
  5. Keep the Pause motion control (aria-pressed) when anything moves for more than 5 seconds.
  6. Run the outcome checks.

Edge cases

  • No WebGL (old devices, blocked GPU): canvas keeps its CSS gradient (data-mode="fallback").
  • Low-end Android: lower the shader scale (0.5) or the fbm octaves (5 -> 3).
  • Safari blend modes: mix-blend-mode: screen on blurred blobs is fine; avoid backdrop-filter stacked on top of the mesh.
  • Light themes: drop blob opacity to ~0.45 and use multiply instead of screen.

Don'ts

  • Never animate width/height/top/left or filter values per frame; transform and opacity only.
  • No full-DPR shader canvases on 3x phones.
  • Do not run more than one heavy background in view at the same time.