{
  "$schema": "../../schema.json",
  "id": "bar-reveal",
  "type": "text",
  "title": "Bar reveal",
  "summary": "A solid bar sweeps across and leaves the line behind it.",
  "tags": [
    "text",
    "graphic",
    "editorial"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "export": "barReveal",
  "signature": "barReveal(el, t, { start, duration, color, curve })",
  "params": [
    {
      "name": "start",
      "type": "number",
      "default": 0,
      "description": "start time in seconds",
      "hidden": true
    },
    {
      "name": "duration",
      "type": "number",
      "default": 0.8,
      "description": "length of the transition in seconds; springs use it to keep their feel",
      "min": 0.2,
      "max": 3,
      "step": 0.05,
      "group": "main"
    },
    {
      "name": "color",
      "type": "color",
      "default": "#fff",
      "description": "color (CSS)",
      "control": "color",
      "group": "main"
    },
    {
      "name": "curve",
      "type": "function",
      "default": "ease.inOutQuart",
      "description": "easing function (from `ease`)",
      "control": "ease",
      "group": "main"
    }
  ],
  "install": {
    "kind": "code"
  },
  "files": [
    {
      "path": "moves/bar-reveal.js",
      "content": "import { ease, progress } from 'paper-motion';\n\n/** A solid bar grows over the line, then pulls away to the other side, leaving the text behind it. */\nexport function barReveal(el, t, { start = 0, duration = 0.8, color = '#fff', curve = ease.inOutQuart } = {}) {\n  if (!el._labBar) {\n    const content = document.createElement('span');\n    content.append(...el.childNodes);\n    const bar = document.createElement('span');\n    Object.assign(bar.style, { position: 'absolute', inset: '0.06em -0.04em', background: color });\n    el.style.position = 'relative'; el.style.display = 'inline-block';\n    el.append(content, bar);\n    el._labBar = { content, bar };\n  }\n  const { content, bar } = el._labBar, half = start + duration / 2;\n  const a = curve(progress(t, start, half)), b = curve(progress(t, half, start + duration));\n  bar.style.transformOrigin = t < half ? '0 50%' : '100% 50%';\n  bar.style.transform = `scaleX(${t < half ? a : 1 - b})`;\n  content.style.opacity = t >= half ? 1 : 0;\n}\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.0"
  },
  "usage": "import { barReveal } from './moves/bar-reveal.js';\n\ns.update((t) => barReveal(el, t, { start: 0.5 }));",
  "notes": [
    "A solid bar grows over the line, then pulls away to the other side, leaving the text behind it."
  ],
  "preview": {
    "video": "previews/bar-reveal.webm",
    "poster": "previews/bar-reveal.jpg"
  },
  "mood": [
    "editorial",
    "bold",
    "minimal"
  ],
  "energy": 3,
  "role": "text",
  "when": [
    "lines of a manifesto",
    "graphic, print-like reveals"
  ]
}