{
  "$schema": "../../schema.json",
  "id": "whip",
  "type": "transition",
  "title": "Whip",
  "summary": "A fast push with horizontal motion blur.",
  "tags": [
    "transition",
    "fast",
    "energetic",
    "motion-blur"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "export": "whip",
  "signature": "whip(a, b, p, { dir, blur, curve })",
  "params": [
    {
      "name": "dir",
      "type": "enum",
      "default": "left",
      "description": "direction",
      "options": [
        "left",
        "right"
      ],
      "control": "segmented",
      "group": "main"
    },
    {
      "name": "blur",
      "type": "number",
      "default": 70,
      "description": "blur strength in px",
      "min": 0,
      "max": 150,
      "step": 1,
      "group": "main"
    },
    {
      "name": "curve",
      "type": "function",
      "default": "ease.inOutQuint",
      "description": "easing function (from `ease`)",
      "control": "ease",
      "group": "main"
    }
  ],
  "install": {
    "kind": "code"
  },
  "files": [
    {
      "path": "moves/whip.js",
      "content": "import { ease, clamp } from 'paper-motion';\nimport { size, hblur } from 'paper-motion/kit';\n\n/** B pushes A out very fast, with horizontal motion blur that follows the speed. `dir` is where A leaves to. */\nexport function whip(a, b, p, { dir = 'left', blur = 70, curve = ease.inOutQuint } = {}) {\n  const q = curve(clamp(p)), v = (curve(clamp(p + 0.01)) - curve(clamp(p - 0.01))) / 0.02;\n  const [w] = size(a, b), s = dir === 'left' ? -1 : 1;\n  a.style.transform = `translateX(${q * w * s}px)`;\n  b.style.transform = `translateX(${(q - 1) * w * s}px)`;\n  const id = (a.parentElement._pmWhipId ??= `pm-whip-${Math.random().toString(36).slice(2, 8)}`); // one blur filter per stage, so two whips on a page don't share it\n  const f = v > 0.15 ? hblur(id, (blur * v) / 5) : 'none';\n  a.style.filter = f; b.style.filter = f;\n  a.style.opacity = 1; b.style.opacity = 1;\n}\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.0"
  },
  "usage": "import { whip } from './moves/whip.js';\n\n// two stacked layers, B above A; in s.update(t), from 2.0 s to 2.6 s:\nwhip(a, b, progress(t, 2.0, 2.6));",
  "notes": [
    "B pushes A out very fast, with horizontal motion blur that follows the speed. `dir` is where A leaves to.",
    "At p = 0 only A shows, at p = 1 only B; keep B above A (z-index)."
  ],
  "preview": {
    "video": "previews/whip.webm",
    "poster": "previews/whip.jpg"
  },
  "mood": [
    "bold",
    "raw"
  ],
  "energy": 5,
  "role": "swap",
  "when": [
    "fast, energetic cuts between scenes",
    "music-driven pieces"
  ]
}