{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sync-grid-demo",
  "type": "registry:block",
  "title": "Sync Grid: Easing",
  "description": "Video Comparison Grid example, Easing: One motion played with four easings. Each card plots its curve with a dot riding it, and moves a card into its slot with the same value. Hover to scrub and watch the others ripple after, or stack them to flip between easings at the exact same moment. A take on the video (video player) and before and after (before after). Fits features sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "features",
    "video",
    "before-and-after",
    "comparison",
    "scrubbing",
    "motion"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/sync-grid#sync-grid-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/sync-grid.json"
  ],
  "files": [
    {
      "path": "components/sync-grid-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { cubicBezier, motion, spring, useTransform, type MotionValue } from \"motion/react\";\n\nimport { SyncGrid, SyncGridItem } from \"@/components/ui/sync-grid\";\n\n// The motion runs over the middle of the clock, with a beat of stillness at\n// each end so the start and the landing both read.\nconst START = 0.1;\nconst SPAN = 0.7;\nconst DURATION = 1.6;\n\n// The graph's value range: room for the spring to overshoot.\nconst LOW = -0.12;\nconst HIGH = 1.22;\n\ntype Curve = { label: string; code: string; ease: (t: number) => number };\n\nconst curves: Curve[] = [\n  { label: \"Linear\", code: \"linear\", ease: (t) => t },\n  {\n    label: \"Ease out\",\n    code: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n    ease: cubicBezier(0.22, 1, 0.36, 1),\n  },\n  {\n    label: \"Ease in-out\",\n    code: \"cubic-bezier(0.65, 0, 0.35, 1)\",\n    ease: cubicBezier(0.65, 0, 0.35, 1),\n  },\n  { label: \"Spring\", code: \"spring · bounce 0.3\", ease: springEase(0.45, 0.3) },\n];\n\nexport function SyncGridDemo() {\n  return (\n    <div className=\"w-full max-w-3xl\">\n      <SyncGrid columns={2} duration={DURATION} fps={60} aspect={4 / 3}>\n        {curves.map((curve) => (\n          <SyncGridItem\n            key={curve.label}\n            label={curve.label}\n            render={(progress) => <EasingScene progress={progress} curve={curve} />}\n          />\n        ))}\n      </SyncGrid>\n    </div>\n  );\n}\n\nfunction EasingScene({ progress, curve }: { progress: MotionValue<number>; curve: Curve }) {\n  const t = useTransform(progress, (p) => Math.min(Math.max((p - START) / SPAN, 0), 1));\n  const value = useTransform(t, (v) => (v >= 1 ? 1 : curve.ease(v)));\n\n  const dotX = useTransform(t, (v) => `${v * 100}%`);\n  const dotY = useTransform(value, (v) => `${(1 - (v - LOW) / (HIGH - LOW)) * 100}%`);\n  const cardY = useTransform(value, (v) => `${(1 - v) * 78}%`);\n  const cardScale = useTransform(value, (v) => 0.82 + 0.18 * v);\n  const cardOpacity = useTransform(value, (v) => Math.min(1, 0.35 + v * 1.6));\n\n  return (\n    <div className=\"@container absolute inset-0 bg-zinc-50 dark:bg-zinc-900\">\n      <code className=\"absolute top-[calc(0.625rem+1.75rem)] left-2.5 font-mono text-[max(9px,2.5cqw)] text-zinc-500 @max-3xs:hidden dark:text-zinc-400\">\n        {curve.code}\n      </code>\n\n      {/* The curve, with the time so far and a dot riding it. */}\n      <div className=\"absolute bottom-[15%] left-[7%] aspect-square w-[36%]\">\n        <div className=\"absolute inset-y-0 left-0 border-l border-zinc-300 dark:border-zinc-700\" />\n        <div\n          className=\"absolute inset-x-0 border-t border-zinc-300 dark:border-zinc-700\"\n          style={{ top: `${(HIGH / (HIGH - LOW)) * 100}%` }}\n        />\n        <div\n          className=\"absolute inset-x-0 border-t border-dashed border-zinc-300 dark:border-zinc-700\"\n          style={{ top: `${((HIGH - 1) / (HIGH - LOW)) * 100}%` }}\n        />\n        <svg viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\" className=\"absolute inset-0 size-full overflow-visible\">\n          <path\n            d={pathOf(curve.ease)}\n            fill=\"none\"\n            className=\"stroke-zinc-900 dark:stroke-zinc-100\"\n            strokeWidth={1.5}\n            vectorEffect=\"non-scaling-stroke\"\n            strokeLinejoin=\"round\"\n          />\n        </svg>\n        <motion.div className=\"absolute inset-0\" style={{ x: dotX }}>\n          <div className=\"absolute inset-y-0 left-0 w-px bg-zinc-900/10 dark:bg-white/10\" />\n          <motion.div className=\"absolute inset-0\" style={{ y: dotY }}>\n            <div className=\"absolute top-0 left-0 size-[max(7px,2.4cqw)] -translate-x-1/2 -translate-y-1/2 rounded-full bg-zinc-900 ring-[max(2px,0.7cqw)] ring-zinc-50 dark:bg-white dark:ring-zinc-900\" />\n          </motion.div>\n        </motion.div>\n      </div>\n\n      {/* The same value moving something: a card rising into its slot. */}\n      <div className=\"absolute top-[24%] right-[7%] bottom-[15%] w-[42%] overflow-hidden rounded-[3.5cqw] bg-white ring-1 ring-zinc-900/[0.06] dark:bg-zinc-950 dark:ring-white/[0.06]\">\n        <div className=\"absolute inset-x-[9%] top-[10%] h-[2.6cqw] w-[38%] rounded-full bg-zinc-200 dark:bg-zinc-800\" />\n        <div className=\"absolute inset-x-[9%] top-[22%] h-[2cqw] w-[58%] rounded-full bg-zinc-100 dark:bg-zinc-900\" />\n        <div className=\"absolute inset-x-[7%] top-[38%] bottom-[8%] rounded-[2.6cqw] border border-dashed border-zinc-300 dark:border-zinc-700\" />\n        <motion.div\n          className=\"absolute inset-x-[7%] top-[38%] bottom-[8%] flex flex-col justify-between rounded-[2.6cqw] bg-zinc-900 p-[3.2cqw] shadow-lg shadow-zinc-900/15 dark:bg-zinc-100 dark:shadow-black/40\"\n          style={{ y: cardY, scale: cardScale, opacity: cardOpacity }}\n        >\n          <div className=\"flex items-center gap-[2cqw]\">\n            <div className=\"size-[5cqw] rounded-full bg-gradient-to-br from-amber-300 to-rose-400\" />\n            <div className=\"flex flex-1 flex-col gap-[1.2cqw]\">\n              <div className=\"h-[1.6cqw] w-[70%] rounded-full bg-white/80 dark:bg-zinc-900/80\" />\n              <div className=\"h-[1.4cqw] w-[45%] rounded-full bg-white/35 dark:bg-zinc-900/35\" />\n            </div>\n          </div>\n          <div className=\"h-[4.4cqw] rounded-[1.4cqw] bg-white/15 dark:bg-zinc-900/10\" />\n        </motion.div>\n      </div>\n    </div>\n  );\n}\n\n/** The curve as an SVG path in a 100 × 100 box, value range LOW to HIGH. */\nfunction pathOf(ease: (t: number) => number) {\n  const points: string[] = [];\n  for (let i = 0; i <= 96; i++) {\n    const t = i / 96;\n    const v = t >= 1 ? 1 : ease(t);\n    points.push(`${(t * 100).toFixed(2)},${((1 - (v - LOW) / (HIGH - LOW)) * 100).toFixed(2)}`);\n  }\n  return `M${points.join(\"L\")}`;\n}\n\n/** A spring sampled over the motion's span, so it reads as an easing curve. */\nfunction springEase(visualDuration: number, bounce: number) {\n  const generator = spring({ keyframes: [0, 1], visualDuration, bounce });\n  const length = DURATION * SPAN * 1000;\n  return (t: number) => generator.next(t * length).value;\n}\n"
    }
  ]
}