Design Vault 用途・構成・配色・本文で検索 /
索引 カテゴリ タグ English
索引に戻る

62 注釈線

動き · LP の構成
注釈線

静止画 — スクリプトが動くと、ここでそのまま動きます

持ち帰る

コピーして貼るか、ファイルに保存して渡す。ネットにつながらない環境には「全部入り」を 1 つ渡せば足りる。

全部入り

motion-callout-lines-everything.md

このパネルの中身を、URL の先にあるファイルの中身まで含めて 1 つにまとめた Markdown

依頼文

1.5 KB
注釈線 — Model-sheet callout lines

設定画のように、人物の全身を左に置き、右に角丸の横長の窓を 4 つ縦に積む。窓は 1 つおきに 8% 右へずらし、各窓の右に「: 01」のような等幅の番号と部位の名前を添える。区画の高さは 300vh、中の箱は 100vh の sticky にする。
窓の中身は同じ人物の絵の一部分で、SVG の `<use>` を窓ごとの viewBox で切り抜き、`preserveAspectRatio="xMidYMid slice"` で窓いっぱいに広げる。
窓 i は --p = 0.06 + 0.18i から 0.18 の間に `clip-path: inset(0 X% 0 0)` で左から開きつつ 48px 右から寄る。その 0.08 後から、人物の上の点(絵に対する 0〜1 の座標)から窓の左端の中央まで、`pathLength="1"` の線を `stroke-dashoffset` で引く。点には差し色の丸を置く。線の両端は描くたびに要素の位置から測り直す。
CSS と素の JavaScript だけで実装し、ライブラリは使わない。

外すと崩れる点:
- 線の端は要素の位置から毎回測る。固定の座標で引くと、幅が変わった画面で窓から外れる
- 窓の拡大は同じ絵の切り抜きにする。別の絵を入れると、線の指す場所と窓の中身が食い違う
- 動きを減らす設定では、窓と線をすべて出した状態で止める

動く実物(1 ファイルで完結する HTML): https://design-vault.pages.dev/designs/motion-callout-lines/demo.html

ファイル

demo.html

13.5 KB

/designs/motion-callout-lines/demo.html — 1 ファイルで完結する HTML。CSS と素の JavaScript だけで、外部からは何も読みません。

中身を見る
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>62 注釈線 — Model-sheet callout lines</title>
<style>
/* dv-motion-base:start */
:root {
  --ground: #FFFFFF;
  --surface: #F3F5F8;
  --ink: #14181F;
  --muted: #5A6472;
  --accent: #1F5FA8;
  --rule: #D8DDE4;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--ground));
  --accent-mid: color-mix(in srgb, var(--accent) 45%, var(--ground));
  --shade: color-mix(in srgb, var(--ink) 14%, transparent);

  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --t-label: 13px;
  --t-body: 16px;
  --t-lead: 20px;
  --t-h2: 32px;
  --t-h1: clamp(40px, 7vw, 72px);

  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 40px;
  --s6: 64px;
  --s7: 104px;

  --radius: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .7s;
  --measure: 1080px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.7;
  font-feature-settings: "palt";
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
.dv-wrap { width: min(100% - 2 * var(--s4), var(--measure)); margin-inline: auto; }
.dv-label {
  min-height: 72vh;
  display: grid;
  align-content: center;
  gap: var(--s3);
  padding-block: var(--s6);
  border-bottom: 1px solid var(--rule);
}
.dv-num { font-family: var(--mono); font-size: var(--t-lead); font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.dv-name { font-size: var(--t-h1); font-weight: 700; line-height: 1.15; letter-spacing: .01em; }
.dv-ai { font-family: var(--mono); font-size: var(--t-lead); color: var(--muted); }
.dv-desc { font-size: var(--t-lead); color: var(--ink); }
.dv-hint { font-size: var(--t-label); color: var(--muted); letter-spacing: .12em; margin-top: var(--s4); }
.dv-stage { padding-block: var(--s7); }
.dv-h2 { font-size: var(--t-h2); font-weight: 700; line-height: 1.3; }
.dv-lead { font-size: var(--t-lead); color: var(--muted); }
.dv-eyebrow { font-family: var(--mono); font-size: var(--t-label); color: var(--accent); letter-spacing: .12em; text-transform: uppercase; }
.dv-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s4); }
.dv-ph {
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-mid) 60%, var(--accent));
  aspect-ratio: 16 / 9;
}
.dv-ph--alt { background: linear-gradient(200deg, var(--surface), var(--accent-soft) 55%, var(--accent-mid)); }
.dv-ph--ink { background: linear-gradient(160deg, var(--ink), color-mix(in srgb, var(--ink) 55%, var(--accent))); }
.dv-end {
  min-height: 60vh;
  display: grid;
  place-items: center;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: .12em;
}
/* dv-motion-base:end */

/* ---- この演出だけの CSS。色は var(--…) か color-mix() のみ ---- */
.f-ink { fill: var(--ink); }
.f-face { fill: var(--surface); }
.f-accent { fill: var(--accent); }
.f-arm { stroke: var(--ink); stroke-width: 30; stroke-linecap: round; fill: none; }
.cl-zone { height: 300vh; }
.cl-box {
  position: sticky; top: 0; height: 100vh; display: grid; align-items: center;
  grid-template-columns: minmax(0, .7fr) minmax(0, 1.6fr); gap: var(--s5); overflow: clip;
}
.cl-fig { height: 86vh; width: 34.4vh; max-width: 100%; justify-self: center; }
.cl-fig svg { width: 100%; height: 100%; display: block; }
.cl-list { display: grid; gap: var(--s4); }
.cl-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s4); }
.cl-item:nth-child(even) { margin-left: 8%; }
.cl-win {
  height: clamp(64px, 15vh, 150px); border-radius: var(--radius); overflow: hidden;
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink);
}
.cl-win svg { width: 100%; height: 100%; display: block; }
.cl-tag { font-family: var(--mono); line-height: 1.1; }
.cl-no { font-size: var(--t-h2); font-weight: 700; color: var(--accent); }
.cl-name { font-family: var(--font); font-size: var(--t-lead); font-weight: 700; }
.cl-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.cl-lines path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--t, 0)); }
.cl-lines circle { fill: var(--accent); stroke: var(--ink); stroke-width: 2; opacity: var(--t, 0); }
.js .cl-item { opacity: var(--o, 0); }
.js .cl-win { clip-path: inset(0 calc((1 - var(--s, 0)) * 100%) 0 0 round var(--radius)); transform: translateX(calc((1 - var(--s, 0)) * 48px)); }
.cl-box { position: sticky; }
@media (max-width: 600px) {
  .cl-box { grid-template-columns: minmax(0, .55fr) minmax(0, 1.45fr); gap: var(--s3); }
  .cl-item { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  .cl-item:nth-child(even) { margin-left: 0; }
  .cl-list { gap: var(--s3); }
  .cl-win { height: 10vh; }
  .cl-no { font-size: var(--t-lead); }
  .cl-name { font-size: var(--t-body); }
  .cl-fig { height: 70vh; width: 28vh; }
}
@media (prefers-reduced-motion: reduce) {
  .js .cl-item { opacity: 1; }
  .js .cl-win { clip-path: none; transform: none; }
}
</style>
</head>
<body data-motion-number="62">
<header class="dv-label">
  <div class="dv-wrap">
    <p class="dv-num">62</p>
    <h1 class="dv-name">注釈線</h1>
    <p class="dv-ai">Model-sheet callout lines</p>
    <p class="dv-desc">人物の各部から線が伸び、番号つきの拡大窓につながる</p>
    <p class="dv-hint">SCROLL ↓</p>
  </div>
</header>

<svg width="0" height="0" style="position: absolute" aria-hidden="true">
  <symbol id="fig-front" viewBox="0 0 400 1000">
    <path class="f-ink" d="M128 120 Q120 40 200 34 Q280 40 272 120 L292 430 L108 430 Z"/>
    <rect class="f-ink" x="182" y="210" width="36" height="50"/>
    <ellipse class="f-face" cx="200" cy="150" rx="60" ry="72"/>
    <path class="f-ink" d="M140 118 Q200 60 262 118 L262 96 Q200 40 138 96 Z"/>
    <ellipse class="f-ink" cx="176" cy="158" rx="7" ry="11"/><ellipse class="f-ink" cx="224" cy="158" rx="7" ry="11"/>
    <path class="f-accent" d="M232 70 l40 -26 l6 36 Z M232 70 l-6 -40 l40 16 Z"/>
    <path class="f-ink" d="M128 252 L272 252 L240 520 L160 520 Z"/>
    <path class="f-accent" d="M160 520 L240 520 L296 712 L104 712 Z"/>
    <rect class="f-ink" x="158" y="712" width="30" height="236"/><rect class="f-ink" x="212" y="712" width="30" height="236"/>
    <ellipse class="f-ink" cx="170" cy="956" rx="30" ry="16"/><ellipse class="f-ink" cx="230" cy="956" rx="30" ry="16"/>
    <path class="f-arm" d="M136 262 L104 516"/><path class="f-arm" d="M264 262 L300 496"/>
    <rect class="f-accent" x="282" y="478" width="42" height="58" rx="6"/>
  </symbol>
</svg>
<main class="dv-stage">
  <div class="dv-wrap">
    <section class="cl-zone" data-progress="pin">
      <div class="cl-box">
        <div class="cl-fig"><svg viewBox="0 0 400 1000" role="img" aria-label="代役の人物"><use href="#fig-front"/></svg></div>
        <ol class="cl-list">
          <li class="cl-item">
            <div class="cl-win"><svg viewBox="216 26 72 64" preserveAspectRatio="xMidYMid slice" aria-hidden="true"><use href="#fig-front" width="400" height="1000"/></svg></div>
            <p class="cl-tag"><span class="cl-no">: 01</span><br><span class="cl-name">髪飾り</span></p>
          </li>
          <li class="cl-item">
            <div class="cl-win"><svg viewBox="150 128 100 60" preserveAspectRatio="xMidYMid slice" aria-hidden="true"><use href="#fig-front" width="400" height="1000"/></svg></div>
            <p class="cl-tag"><span class="cl-no">: 02</span><br><span class="cl-name">目元</span></p>
          </li>
          <li class="cl-item">
            <div class="cl-win"><svg viewBox="270 470 66 74" preserveAspectRatio="xMidYMid slice" aria-hidden="true"><use href="#fig-front" width="400" height="1000"/></svg></div>
            <p class="cl-tag"><span class="cl-no">: 03</span><br><span class="cl-name">持ち物</span></p>
          </li>
          <li class="cl-item">
            <div class="cl-win"><svg viewBox="128 930 144 46" preserveAspectRatio="xMidYMid slice" aria-hidden="true"><use href="#fig-front" width="400" height="1000"/></svg></div>
            <p class="cl-tag"><span class="cl-no">: 04</span><br><span class="cl-name">靴</span></p>
          </li>
        </ol>
        <svg class="cl-lines" aria-hidden="true"></svg>
      </div>
    </section>
  </div>
</main>

<footer class="dv-end">END — 62 注釈線</footer>

<script>
/* dv-motion-helpers:start */
const dvReduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
document.documentElement.classList.add('js');

/**
 * 画面に入った要素へ .is-in を付ける。
 * data-reveal="repeat" の要素は画面を出たら外す(何度でも再生)。
 */
function dvReveal(selector = '[data-reveal]', { threshold = 0.2, rootMargin = '0px 0px -8% 0px' } = {}) {
  const els = [...document.querySelectorAll(selector)];
  if (dvReduce || !('IntersectionObserver' in window)) {
    els.forEach((el) => el.classList.add('is-in'));
    return;
  }
  const io = new IntersectionObserver((entries) => {
    for (const e of entries) {
      if (e.isIntersecting) {
        e.target.classList.add('is-in');
        if (e.target.dataset.reveal !== 'repeat') io.unobserve(e.target);
      } else if (e.target.dataset.reveal === 'repeat') {
        e.target.classList.remove('is-in');
      }
    }
  }, { threshold, rootMargin });
  els.forEach((el) => io.observe(el));
}

/**
 * スクロール量を 0〜1 にして、各 [data-progress] 要素の CSS 変数 --p に書く。
 *   data-progress="through" : 要素の上端が画面の下端に来たとき 0、下端が画面の上端を抜けたとき 1
 *   data-progress="pin"     : 要素の上端が画面の上端に来たとき 0、下端が画面の下端に来たとき 1
 *                             (中に position: sticky の箱を持つ、背の高い区画用)
 *   data-progress="page"    : ページ全体のスクロール量
 * onUpdate(el, p) を渡すと、値が変わるたびに呼ばれる。
 */
function dvProgress(onUpdate) {
  const els = [...document.querySelectorAll('[data-progress]')];
  const clamp = (n) => Math.min(1, Math.max(0, n));
  let queued = false;
  const measure = () => {
    queued = false;
    const vh = window.innerHeight;
    for (const el of els) {
      const r = el.getBoundingClientRect();
      let p;
      if (el.dataset.progress === 'pin') p = r.height > vh ? -r.top / (r.height - vh) : 0;
      else if (el.dataset.progress === 'page') {
        const max = document.documentElement.scrollHeight - vh;
        p = max > 0 ? window.scrollY / max : 0;
      } else p = (vh - r.top) / (vh + r.height);
      p = clamp(p);
      el.style.setProperty('--p', p.toFixed(4));
      if (onUpdate) onUpdate(el, p);
    }
  };
  const request = () => {
    if (!queued) { queued = true; requestAnimationFrame(measure); }
  };
  addEventListener('scroll', request, { passive: true });
  addEventListener('resize', request);
  measure();
}
/* dv-motion-helpers:end */

/* ---- この演出だけの JS ---- */
// 設定画の注釈。窓が 1 つずつ入り、人物の上の点から窓へ線が引かれる。線の両端は描くたびに測り直す。
const POINTS = [[0.63, 0.06], [0.5, 0.158], [0.76, 0.507], [0.43, 0.956]]; // 人物の絵の上の点(0〜1)
const box = document.querySelector('.cl-box'), figEl = box.querySelector('.cl-fig svg');
const items = [...box.querySelectorAll('.cl-item')], lines = box.querySelector('.cl-lines');
const NS = 'http://www.w3.org/2000/svg';
const parts = items.map(() => {
  const g = document.createElementNS(NS, 'g'), path = document.createElementNS(NS, 'path'), dot = document.createElementNS(NS, 'circle');
  path.setAttribute('pathLength', '1'); dot.setAttribute('r', '6');
  g.append(path, dot); lines.appendChild(g);
  return g;
});
const clamp = (n) => Math.min(1, Math.max(0, n));
const ease = (t) => 1 - Math.pow(1 - t, 3);
dvProgress((el, p) => {
  const b = box.getBoundingClientRect(), f = figEl.getBoundingClientRect();
  lines.setAttribute('viewBox', `0 0 ${b.width} ${b.height}`);
  items.forEach((item, i) => {
    // 窓 i は p = 0.06 + 0.18i から入り、線はその少し後から引かれる。最後の窓も p = 0.9 までに揃う。
    const a = 0.06 + i * 0.18;
    const s = dvReduce ? 1 : ease(clamp((p - a) / 0.18));
    const t = dvReduce ? 1 : clamp((p - a - 0.08) / 0.18);
    item.style.setProperty('--o', s > 0 ? 1 : 0);
    item.style.setProperty('--s', s.toFixed(4));
    const w = item.querySelector('.cl-win').getBoundingClientRect();
    // 人物の絵は箱の中に縦横比を保って収まる(meet)ので、描かれた範囲を出してから点を置く。
    const k = Math.min(f.width / 400, f.height / 1000), dx = (f.width - 400 * k) / 2, dy = (f.height - 1000 * k) / 2;
    const x1 = f.left - b.left + dx + POINTS[i][0] * 400 * k, y1 = f.top - b.top + dy + POINTS[i][1] * 1000 * k;
    const x2 = w.left - b.left, y2 = w.top - b.top + w.height / 2;
    const [path, dot] = parts[i].children;
    path.setAttribute('d', `M${x1.toFixed(1)} ${y1.toFixed(1)} L${x2.toFixed(1)} ${y2.toFixed(1)}`);
    dot.setAttribute('cx', x1.toFixed(1)); dot.setAttribute('cy', y1.toFixed(1));
    parts[i].style.setProperty('--t', t.toFixed(4));
  });
});
</script>
</body>
</html>

/ai/assets/motion-callout-lines.json