{
  "id": "motion:motion-circular-progress",
  "slug": "motion-circular-progress",
  "kind": "motion",
  "title": {
    "ja": "円形プログレス",
    "en": "Circular scroll progress"
  },
  "aiName": "Circular scroll progress",
  "summary": {
    "ja": "円が読了量を示し、頂上に戻れる",
    "en": "A ring shows how far you have read, and lets you return to the top"
  },
  "number": 42,
  "group": "ambient",
  "techniques": [
    "scroll-progress",
    "svg"
  ],
  "rules": [
    {
      "ja": "輪の進みはページ全体のスクロール量と一致し、最後の 1 段で 100% に届く",
      "en": "The ring tracks whole-page scroll and reaches 100% at the bottom"
    },
    {
      "ja": "動きを減らす設定を除き、「↑」は 90% を超えたときだけ出し、それ以外では押せない",
      "en": "Except under reduced motion, the up arrow appears only above 90% and is not clickable below it"
    },
    {
      "ja": "動きを減らす設定では、輪は完成した状態で止めて見せる",
      "en": "With reduced motion, the ring stays drawn complete"
    }
  ],
  "reproduction": {
    "prompt": {
      "ja": "円形プログレス — Circular scroll progress\n\n画面の右下に、直径 72px の円形プログレスを固定して置く。外側の輪は SVG の circle で、stroke-dasharray を 1（pathLength=\"1\"）にし、stroke-dashoffset を 1 から 0 へ動かして、ページ全体のスクロール量 0〜100% に合わせて輪を時計回りに描く。\n輪の中央には現在の百分率を「45%」のように表示し、等幅の数字を使う。\n読了量が 90% を超えたら中央の表示を「↑」に切り替え、押すと先頭へ滑らかにスクロールして戻る（動きを減らす設定では即時）。\n輪の線は --accent、地の輪は --rule で描き、色は :root の名前だけを使う。CSS と素の JavaScript だけで実装し、ライブラリは使わない。\n\n外すと崩れる点:\n- 輪の進みはページ全体のスクロール量と一致し、最後の 1 段で 100% に届く\n- 動きを減らす設定を除き、「↑」は 90% を超えたときだけ出し、それ以外では押せない\n- 動きを減らす設定では、輪は完成した状態で止めて見せる\n\n動く実物（1 ファイルで完結する HTML）: https://design-vault.pages.dev/designs/motion-circular-progress/demo.html",
      "en": "Circular scroll progress — Circular scroll progress\n\nFix a 72px circular progress indicator at the bottom-right of the screen. The outer ring is an SVG circle with pathLength=\"1\" and stroke-dasharray 1, and its stroke-dashoffset moves from 1 to 0 so the ring draws clockwise as the page scroll goes from 0% to 100%.\nShow the current percentage in the centre in tabular numerals, for example \"45%\".\nOnce progress passes 90%, swap the centre to \"↑\"; pressing it scrolls smoothly back to the top (instantly when reduced motion is set). Draw the progress stroke in --accent and the track in --rule, and use only the named colour roles.\nImplement with CSS and plain JavaScript only; do not use a library.\n\nDo not drop:\n- The ring tracks whole-page scroll and reaches 100% at the bottom\n- Except under reduced motion, the up arrow appears only above 90% and is not clickable below it\n- With reduced motion, the ring stays drawn complete\n\nA working example (one self-contained HTML file): https://design-vault.pages.dev/designs/motion-circular-progress/demo.html"
    },
    "code": {
      "url": "https://design-vault.pages.dev/designs/motion-circular-progress/demo.html",
      "html": "<!doctype html>\n<html lang=\"ja\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>42 円形プログレス — Circular scroll progress</title>\n<style>\n/* dv-motion-base:start */\n:root {\n  --ground: #FFFFFF;\n  --surface: #F3F5F8;\n  --ink: #14181F;\n  --muted: #5A6472;\n  --accent: #1F5FA8;\n  --rule: #D8DDE4;\n  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--ground));\n  --accent-mid: color-mix(in srgb, var(--accent) 45%, var(--ground));\n  --shade: color-mix(in srgb, var(--ink) 14%, transparent);\n\n  --font: \"Zen Kaku Gothic New\", \"Hiragino Sans\", \"Noto Sans JP\", \"Yu Gothic\", system-ui, sans-serif;\n  --mono: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace;\n\n  --t-label: 13px;\n  --t-body: 16px;\n  --t-lead: 20px;\n  --t-h2: 32px;\n  --t-h1: clamp(40px, 7vw, 72px);\n\n  --s1: 4px;\n  --s2: 8px;\n  --s3: 16px;\n  --s4: 24px;\n  --s5: 40px;\n  --s6: 64px;\n  --s7: 104px;\n\n  --radius: 12px;\n  --ease: cubic-bezier(.2, .7, .2, 1);\n  --dur: .7s;\n  --measure: 1080px;\n}\n*, *::before, *::after { box-sizing: border-box; }\nhtml { -webkit-text-size-adjust: 100%; }\nbody {\n  margin: 0;\n  background: var(--ground);\n  color: var(--ink);\n  font-family: var(--font);\n  font-size: var(--t-body);\n  line-height: 1.7;\n  font-feature-settings: \"palt\";\n  overflow-x: hidden;\n}\nh1, h2, h3, p, ul, ol, figure { margin: 0; padding: 0; }\nul, ol { list-style: none; }\n.dv-wrap { width: min(100% - 2 * var(--s4), var(--measure)); margin-inline: auto; }\n.dv-label {\n  min-height: 72vh;\n  display: grid;\n  align-content: center;\n  gap: var(--s3);\n  padding-block: var(--s6);\n  border-bottom: 1px solid var(--rule);\n}\n.dv-num { font-family: var(--mono); font-size: var(--t-lead); font-weight: 700; color: var(--accent); letter-spacing: .04em; }\n.dv-name { font-size: var(--t-h1); font-weight: 700; line-height: 1.15; letter-spacing: .01em; }\n.dv-ai { font-family: var(--mono); font-size: var(--t-lead); color: var(--muted); }\n.dv-desc { font-size: var(--t-lead); color: var(--ink); }\n.dv-hint { font-size: var(--t-label); color: var(--muted); letter-spacing: .12em; margin-top: var(--s4); }\n.dv-stage { padding-block: var(--s7); }\n.dv-h2 { font-size: var(--t-h2); font-weight: 700; line-height: 1.3; }\n.dv-lead { font-size: var(--t-lead); color: var(--muted); }\n.dv-eyebrow { font-family: var(--mono); font-size: var(--t-label); color: var(--accent); letter-spacing: .12em; text-transform: uppercase; }\n.dv-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s4); }\n.dv-ph {\n  border-radius: var(--radius);\n  background: linear-gradient(135deg, var(--accent-soft), var(--accent-mid) 60%, var(--accent));\n  aspect-ratio: 16 / 9;\n}\n.dv-ph--alt { background: linear-gradient(200deg, var(--surface), var(--accent-soft) 55%, var(--accent-mid)); }\n.dv-ph--ink { background: linear-gradient(160deg, var(--ink), color-mix(in srgb, var(--ink) 55%, var(--accent))); }\n.dv-end {\n  min-height: 60vh;\n  display: grid;\n  place-items: center;\n  border-top: 1px solid var(--rule);\n  color: var(--muted);\n  font-family: var(--mono);\n  font-size: var(--t-label);\n  letter-spacing: .12em;\n}\n/* dv-motion-base:end */\n\n/* ---- この演出だけの CSS。色は var(--…) か color-mix() のみ ---- */\n.stack { display: grid; gap: var(--s6); }\n.ring {\n  position: fixed;\n  right: var(--s3);\n  bottom: var(--s3);\n  z-index: 10;\n  width: 72px;\n  height: 72px;\n  border-radius: 50%;\n  background: var(--ground);\n  box-shadow: 0 2px 12px var(--shade);\n  display: grid;\n  place-items: center;\n}\n.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }\n.ring-track { fill: none; stroke: var(--rule); stroke-width: 4; }\n.ring-fg {\n  fill: none;\n  stroke: var(--accent);\n  stroke-width: 4;\n  stroke-linecap: round;\n  stroke-dasharray: 1;\n  stroke-dashoffset: calc(1 - var(--p, 0));\n  transform: rotate(-90deg);\n  transform-origin: 50% 50%;\n}\n.ring-num {\n  font-family: var(--mono);\n  font-size: var(--t-label);\n  font-weight: 700;\n  color: var(--ink);\n  font-variant-numeric: tabular-nums;\n  transition: opacity var(--dur) var(--ease);\n}\n.ring-btn {\n  position: absolute;\n  inset: 0;\n  border: 0;\n  border-radius: 50%;\n  background: transparent;\n  color: var(--accent);\n  font: inherit;\n  font-size: var(--t-lead);\n  font-weight: 700;\n  cursor: pointer;\n  opacity: 0;\n  pointer-events: none;\n}\n.ring.is-top .ring-num { opacity: 0; }\n.ring.is-top .ring-btn { opacity: 1; pointer-events: auto; }\n.ring-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }\n\n@media (prefers-reduced-motion: reduce) {\n  .ring-fg { stroke-dashoffset: 0; }\n}\n</style>\n</head>\n<body data-motion-number=\"42\">\n<header class=\"dv-label\">\n  <div class=\"dv-wrap\">\n    <p class=\"dv-num\">42</p>\n    <h1 class=\"dv-name\">円形プログレス</h1>\n    <p class=\"dv-ai\">Circular scroll progress</p>\n    <p class=\"dv-desc\">円が読了量を示し、頂上に戻れる</p>\n    <p class=\"dv-hint\">SCROLL ↓</p>\n  </div>\n</header>\n\n<main class=\"dv-stage\">\n  <div class=\"dv-wrap stack\">\n    <section class=\"dv-card\">\n      <p class=\"dv-eyebrow\">Section 1</p>\n      <h2 class=\"dv-h2\">見出しが入ります</h2>\n      <p class=\"dv-lead\">本文のダミーです。右下の輪が、どこまで読んだかを示します。</p>\n    </section>\n    <div class=\"dv-ph\"></div>\n    <section class=\"dv-card\">\n      <p class=\"dv-eyebrow\">Section 2</p>\n      <h2 class=\"dv-h2\">見出しが入ります</h2>\n      <p class=\"dv-lead\">本文のダミーです。読み進めるほど、輪の線が伸びていきます。</p>\n    </section>\n    <div class=\"dv-ph dv-ph--alt\"></div>\n    <section class=\"dv-card\">\n      <p class=\"dv-eyebrow\">Section 3</p>\n      <h2 class=\"dv-h2\">見出しが入ります</h2>\n      <p class=\"dv-lead\">本文のダミーです。ここまでの量が、輪の中の百分率で読めます。</p>\n    </section>\n    <div class=\"dv-ph dv-ph--ink\"></div>\n    <section class=\"dv-card\">\n      <p class=\"dv-eyebrow\">Section 4</p>\n      <h2 class=\"dv-h2\">見出しが入ります</h2>\n      <p class=\"dv-lead\">本文のダミーです。終わり近くで、輪の中の印が矢印に変わります。</p>\n    </section>\n    <div class=\"dv-ph\"></div>\n    <section class=\"dv-card\">\n      <p class=\"dv-eyebrow\">Section 5</p>\n      <h2 class=\"dv-h2\">見出しが入ります</h2>\n      <p class=\"dv-lead\">本文のダミーです。矢印を押すと、先頭まで戻ります。</p>\n    </section>\n    <div class=\"dv-ph dv-ph--alt\"></div>\n  </div>\n</main>\n\n<div class=\"ring\" data-progress=\"page\">\n  <svg viewBox=\"0 0 72 72\" aria-hidden=\"true\">\n    <circle class=\"ring-track\" cx=\"36\" cy=\"36\" r=\"30\"></circle>\n    <circle class=\"ring-fg\" cx=\"36\" cy=\"36\" r=\"30\" pathLength=\"1\"></circle>\n  </svg>\n  <span class=\"ring-num\">0%</span>\n  <button class=\"ring-btn\" type=\"button\" aria-label=\"先頭へ戻る\" disabled>↑</button>\n</div>\n\n<footer class=\"dv-end\">END — 42 円形プログレス</footer>\n\n<script>\n/* dv-motion-helpers:start */\nconst dvReduce = matchMedia('(prefers-reduced-motion: reduce)').matches;\ndocument.documentElement.classList.add('js');\n\n/**\n * 画面に入った要素へ .is-in を付ける。\n * data-reveal=\"repeat\" の要素は画面を出たら外す（何度でも再生）。\n */\nfunction dvReveal(selector = '[data-reveal]', { threshold = 0.2, rootMargin = '0px 0px -8% 0px' } = {}) {\n  const els = [...document.querySelectorAll(selector)];\n  if (dvReduce || !('IntersectionObserver' in window)) {\n    els.forEach((el) => el.classList.add('is-in'));\n    return;\n  }\n  const io = new IntersectionObserver((entries) => {\n    for (const e of entries) {\n      if (e.isIntersecting) {\n        e.target.classList.add('is-in');\n        if (e.target.dataset.reveal !== 'repeat') io.unobserve(e.target);\n      } else if (e.target.dataset.reveal === 'repeat') {\n        e.target.classList.remove('is-in');\n      }\n    }\n  }, { threshold, rootMargin });\n  els.forEach((el) => io.observe(el));\n}\n\n/**\n * スクロール量を 0〜1 にして、各 [data-progress] 要素の CSS 変数 --p に書く。\n *   data-progress=\"through\" : 要素の上端が画面の下端に来たとき 0、下端が画面の上端を抜けたとき 1\n *   data-progress=\"pin\"     : 要素の上端が画面の上端に来たとき 0、下端が画面の下端に来たとき 1\n *                             （中に position: sticky の箱を持つ、背の高い区画用）\n *   data-progress=\"page\"    : ページ全体のスクロール量\n * onUpdate(el, p) を渡すと、値が変わるたびに呼ばれる。\n */\nfunction dvProgress(onUpdate) {\n  const els = [...document.querySelectorAll('[data-progress]')];\n  const clamp = (n) => Math.min(1, Math.max(0, n));\n  let queued = false;\n  const measure = () => {\n    queued = false;\n    const vh = window.innerHeight;\n    for (const el of els) {\n      const r = el.getBoundingClientRect();\n      let p;\n      if (el.dataset.progress === 'pin') p = r.height > vh ? -r.top / (r.height - vh) : 0;\n      else if (el.dataset.progress === 'page') {\n        const max = document.documentElement.scrollHeight - vh;\n        p = max > 0 ? window.scrollY / max : 0;\n      } else p = (vh - r.top) / (vh + r.height);\n      p = clamp(p);\n      el.style.setProperty('--p', p.toFixed(4));\n      if (onUpdate) onUpdate(el, p);\n    }\n  };\n  const request = () => {\n    if (!queued) { queued = true; requestAnimationFrame(measure); }\n  };\n  addEventListener('scroll', request, { passive: true });\n  addEventListener('resize', request);\n  measure();\n}\n/* dv-motion-helpers:end */\n\n/* ---- この演出だけの JS ---- */\ndvReveal();\n\nconst ring = document.querySelector('.ring');\nconst ringNum = ring.querySelector('.ring-num');\nconst ringBtn = ring.querySelector('.ring-btn');\ndvProgress((el, p) => {\n  // 動きを減らす設定では、輪は完成した状態で止めて見せる\n  const shown = dvReduce ? 1 : p;\n  const top = shown > 0.9;\n  ringNum.textContent = Math.round(shown * 100) + '%';\n  el.classList.toggle('is-top', top);\n  ringBtn.disabled = !top;\n});\nringBtn.addEventListener('click', () => {\n  scrollTo({ top: 0, behavior: dvReduce ? 'auto' : 'smooth' });\n});\n</script>\n</body>\n</html>\n"
    }
  },
  "license": "Original",
  "catalogVersion": 1,
  "designSchemaVersion": 2,
  "capabilities": [
    "live-preview",
    "copy-prompt",
    "get-code"
  ],
  "reusePolicy": "construction-reuse",
  "urls": {
    "ja": "https://design-vault.pages.dev/designs/motion-circular-progress",
    "en": "https://design-vault.pages.dev/en/designs/motion-circular-progress",
    "json": "https://design-vault.pages.dev/ai/assets/motion-circular-progress.json",
    "designJson": null
  }
}