Clip-path Wipe Reveal — Scroll-scrubbed Works Grid
A works photo grid where each image appears as a cover is pulled away, not faded in. A clip-path: inset() mask is scrubbed by scroll and closes again when you scroll back. Rows open from the left, the top and the right, and tiles stagger within a row. A strip at the top shows the same photo closed, half open and fully open, and each row label shows its direction and how far it has opened. The closed cover names its direction and an amber line follows the mask edge, so a still frame still reads as a wipe. JS only writes a progress value --p on each row and tile; CSS calc turns it into the mask (no dependencies, no image assets). Keyboard-focused tiles open fully, and reduced-motion pins everything open. A short guide at the end points to where to swap photos, change direction, stagger and the narrow-screen order.
Preview
BLK-59実績・事例撮り下ろし
7 点
スクロールしたぶんだけ、現場が開いていく
写真は浮かび上がるのではなく、覆いが引かれて現れます。行ごとに開く向きを変えました。
20252026撮り下ろし 7 点
実績の一覧を見るRead the full description
A works photo grid where each image appears as a cover is pulled away, not faded in. A clip-path: inset() mask is scrubbed by scroll and closes again when you scroll back. Rows open from the left, the top and the right, and tiles stagger within a row. A strip at the top shows the same photo closed, half open and fully open, and each row label shows its direction and how far it has opened. The closed cover names its direction and an amber line follows the mask edge, so a still frame still reads as a wipe. JS only writes a progress value --p on each row and tile; CSS calc turns it into the mask (no dependencies, no image assets). Keyboard-focused tiles open fully, and reduced-motion pins everything open. A short guide at the end points to where to swap photos, change direction, stagger and the narrow-screen order.
- Added:
- 2026-09-13
- Updated:
- 2026-11-15
- Dependencies:
- None
- tags
- #works #case-study #gallery #photo-grid #clip-path #mask-reveal #wipe #scroll-linked #stagger #css-gradient #no-image #no-dependency #scroll-reveal
"use client";
import { useEffect, useRef, type CSSProperties } from "react";
/**
* clip-pathワイプreveal フォトグリッド(BLK-59)
*
* 差別化メモ(既存の実績・事例は「並べ方」で分かれている: 等間隔グリッド / 不揃いグリッド /
* 横送りカルーセル / 3Dティルト / WebGL巡回)。本ブロックだけは**並びではなく出現そのものが主題**で、
* 一度きりのトリガーではなくスクロール量に連動してマスクが開き**戻すと閉じる(可逆・連続)**。
* 行ごとに開く向きが反転し、情報は番号・見出し・業種・年のみで抜粋もタグチップも持たない。
* 節の定型も意図的に外した: 英字キッカーなし / 角丸ゼロ(全て角のある面)。
*
* 汎用技法メモ:
* - **フェードでなくマスクを開く**: 出現を opacity で作ると「薄い絵が濃くなる」だけだが、
* clip-path: inset() を 100% から 0 へ縮めると「覆いが引かれて絵が出る」写真的な出現になる。
* マスクは矩形1枚なので paint の範囲が限定され、タイル数を抑えれば実用域に収まる
* (transform/opacity と違い合成だけでは済まない点は自覚して使う)。
* - **内側を逆へ寄せて「動いていない写真」に見せる**: マスクだけ動かすと絵まで流れて見えるので、
* 中の画(.cwg-shot)を閉じ側へ translate しておき 0 へ戻す。周囲 12% ぶん大きく敷いて
* ずらしても地が出ないようにするのが要点。
* - **開いている途中を読めるようにする**: 覆いの面(.cwg-cover)に開く向きを書き、マスクの境目に
* アンバーの線(.cwg-edge)を transform で沿わせる。止めた1枚の画面でも「どちらへ開くか」が分かる。
* - **進捗は要素ごとに自分で測る**: JS は rAF で合体した1ハンドラが各 .cwg-t へ --p(0 から 1)を
* 書くだけ。節に1本の進捗で全部を駆動すると、縦に長い節では下の行が画面へ入る前に開き切る
* (節の高さと各行の到達時刻が比例しないため)。分母に要素自身の高さを混ぜておくと、
* 一覧の縮小プレビューのように小さく描画されたときも最後まで到達する。
* 行内のスタッガーだけは --t: clamp(0, (--p - --s) / --w, 1) としてCSSのcalcに任せる
* (インラインの --s を渡すだけなので、タイルを増やしてもJSの分岐が増えない)。
* - **閉じたマスクにフォーカスを入れない**: .cwg-t:focus-within { --t: 1 } を stylesheet 側に置くと
* (:focus-within のほうが詳細度が高いので)キーボードで到達したタイルだけ必ず開き切る。
* フォーカスリングが切られないよう、clip-path をかけるのは <a> の内側の要素だけにする。
* - **reduced-motion はJSでなくCSSで畳む**: @media で --p: 1 !important を当てるとJSが書く
* インラインスタイルより強いので「最初から開き切っている」が唯一の状態になる(JSもリスナーを張らない)。
*/
type Work = {
no: string;
title: string;
field: string;
year: string;
/** CSSグラデーションだけで組んだ画(shots の index)。写真へ替えるときは Shot を <img> にする */
shot: number;
aspect: string;
};
const works: Work[] = [
{ no: "01", title: "朝の外観から撮り直す", field: "医療", year: "2026", shot: 0, aspect: "aspect-[16/10]" },
{ no: "02", title: "焙煎の熱を色で残す", field: "飲食", year: "2025", shot: 2, aspect: "aspect-[4/5]" },
{ no: "03", title: "縦格子と影の反復", field: "建築", year: "2026", shot: 1, aspect: "aspect-[3/4]" },
{ no: "04", title: "机上に並んだ試作", field: "製造", year: "2025", shot: 3, aspect: "aspect-[3/4]" },
{ no: "05", title: "夜の工場を見上げる", field: "製造", year: "2026", shot: 5, aspect: "aspect-[3/4]" },
{ no: "06", title: "海へ開くテラス", field: "宿泊", year: "2026", shot: 4, aspect: "aspect-[4/5]" },
{ no: "07", title: "広場を真上から", field: "公共", year: "2025", shot: 6, aspect: "aspect-[16/10]" },
];
type Dir = "l" | "d" | "r";
/** 開く向きの呼び名と、覆いの面に書く矢印 */
const DIRS: Record<Dir, { label: string; arrow: string }> = {
l: { label: "左から", arrow: "→" },
d: { label: "上から", arrow: "↓" },
r: { label: "右から", arrow: "←" },
};
/**
* 行。dir が開く向き(l=左から / d=上から / r=右から)。
* 列比を行ごとに変え、等間隔の格子に見せない。640px未満は1列で items の順に縦へ積む。
*/
const rows: { dir: Dir; cols: string; items: number[] }[] = [
// 縦横比の違うカットが並ぶ行は sm:items-end。背の低いほうを下端で揃え、
// 余った空きを上へ逃がすと「穴」ではなく段差の律動になる。
{ dir: "l", cols: "sm:grid-cols-[1.32fr_1fr] sm:items-end", items: [0, 1] },
{ dir: "d", cols: "sm:grid-cols-3", items: [2, 3, 4] },
{ dir: "r", cols: "sm:grid-cols-[1fr_1.32fr] sm:items-end", items: [5, 6] },
];
/** 行内で1枚ごとにずらす開始位置(ローカル進捗の上の座標) */
const STAGGER = 0.1;
/** 状態見本: 同じ画を未展開・途中・全開で並べる */
const SAMPLES = [
{ t: 0, label: "未展開" },
{ t: 0.5, label: "途中" },
{ t: 1, label: "全開" },
] as const;
const SOURCES = [
{
label: "MDN「clip-path」",
href: "https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path",
note: "Baseline Widely available(2020年1月から主要ブラウザで使える)。inset() などの基本図形どうしはアニメーションできる",
},
{
label: "MDN「prefers-reduced-motion」",
href: "https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion",
note: "Baseline Widely available(2020年1月から)。この見本は reduce のとき全開で固定する",
},
{
label: "W3C「Understanding SC 2.3.3 Animation from Interactions」",
href: "https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html",
note: "レベルAAA。操作で起きる動きは、機能に欠かせない場合を除き止められること。十分な方法に C39(CSS の prefers-reduced-motion)を挙げる(2025-09-16 更新版)",
},
{
label: "MDN「view()」(animation-timeline)",
href: "https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timeline/view",
note: "Baseline Newly available(2026年10月から)。古い端末では動かないことがあるため、この見本は JS で進捗を書く方式のまま",
},
] as const;
/** 画像素材の代替。1枚の画=重ねた絶対配置レイヤ(すべてCSSグラデーションと図形) */
const shots: CSSProperties[][] = [
// 00 朝の外観
[
{ inset: 0, background: "linear-gradient(180deg,#fbe9cf 0%,#f7dcb4 34%,#efcf9f 52%,#d8cbbb 52%,#bfb3a5 100%)" },
{
inset: 0,
background:
"radial-gradient(circle at 74% 24%, #fff7e6 0 4.5%, rgba(245,158,11,0.75) 4.6% 6.5%, rgba(245,158,11,0.18) 6.6% 16%, transparent 30%)",
},
{
left: 0,
right: 0,
top: "36%",
height: "18%",
background: "#e4cdb0",
clipPath: "polygon(0 70%, 18% 38%, 34% 60%, 56% 24%, 78% 58%, 100% 40%, 100% 100%, 0 100%)",
},
{
left: "8%",
right: "46%",
top: "28%",
bottom: "14%",
background: "linear-gradient(90deg,#2b2522 0 62%,#3d3530 62% 100%)",
clipPath: "polygon(0 20%, 62% 0, 100% 12%, 100% 100%, 0 100%)",
},
{
left: "12%",
right: "52%",
top: "42%",
bottom: "20%",
background: "radial-gradient(rgba(253,224,150,0.95) 0 2px, transparent 2.6px) 0 0/16px 20px",
},
{
left: "52%",
right: "10%",
top: "44%",
bottom: "14%",
background: "repeating-linear-gradient(90deg,#5e554e 0 18px,#6b625a 18px 20px)",
clipPath: "polygon(0 16%, 100% 0, 100% 100%, 0 100%)",
},
{ left: 0, right: 0, bottom: 0, height: "14%", background: "linear-gradient(180deg,#a89b8c,#8d8174)" },
{
left: "8%",
right: "-20%",
bottom: 0,
height: "14%",
background: "linear-gradient(90deg, rgba(28,25,23,0.42), rgba(28,25,23,0))",
clipPath: "polygon(0 0, 60% 0, 100% 100%, 0 100%)",
},
],
// 01 縦格子
[
{ inset: 0, background: "linear-gradient(180deg,#fdf6ea 0%,#f3e6d1 100%)" },
{ inset: 0, background: "repeating-linear-gradient(90deg,#3a322d 0 9px,rgba(58,50,45,0) 9px 26px)" },
{
inset: 0,
background: "repeating-linear-gradient(90deg,rgba(0,0,0,0) 0 9px,rgba(245,158,11,0.32) 9px 13px,rgba(0,0,0,0) 13px 26px)",
},
{ inset: 0, background: "linear-gradient(160deg, rgba(28,25,23,0.72) 0 30%, rgba(28,25,23,0) 58%)" },
{ left: 0, right: 0, top: "70%", bottom: 0, background: "linear-gradient(180deg,#d6c3a6,#b9a487)" },
{
left: 0,
right: 0,
top: "70%",
bottom: 0,
background: "repeating-linear-gradient(100deg, rgba(28,25,23,0.35) 0 9px, rgba(28,25,23,0) 9px 26px)",
},
],
// 02 焙煎(カップを真上から)
[
{ inset: 0, background: "radial-gradient(120% 90% at 30% 20%, #6b4a32 0%, #3b2a1f 55%, #1f1712 100%)" },
{
inset: 0,
background: "repeating-linear-gradient(8deg, rgba(255,255,255,0.03) 0 2px, rgba(255,255,255,0) 2px 9px)",
},
{
left: "18%",
top: "26%",
width: "64%",
aspectRatio: "1",
borderRadius: "50%",
background: "radial-gradient(circle, #f5efe6 0 58%, #e2d7c8 58% 64%, rgba(0,0,0,0) 64%)",
boxShadow: "0 18px 30px rgba(0,0,0,0.45)",
},
{
left: "28%",
top: "35.5%",
width: "44%",
aspectRatio: "1",
borderRadius: "50%",
background:
"radial-gradient(circle at 42% 40%, #b45309 0 8%, #7c3d12 22%, #3b1d0c 58%, #c08a52 62%, #f3e4cf 68%, #fbf7f0 100%)",
},
{
left: "-20%",
right: "-20%",
top: "-10%",
height: "60%",
background: "linear-gradient(115deg, rgba(255,237,200,0) 30%, rgba(255,237,200,0.22) 46%, rgba(255,237,200,0) 62%)",
},
],
// 03 机上の試作
[
{ inset: 0, background: "linear-gradient(135deg,#efe7dc 0%,#e2d6c5 100%)" },
{ inset: 0, background: "repeating-linear-gradient(0deg, rgba(120,98,72,0.07) 0 1px, rgba(0,0,0,0) 1px 9px)" },
{
left: "12%",
top: "14%",
width: "40%",
height: "34%",
background: "#fbfaf7",
boxShadow: "0 10px 22px rgba(60,40,20,0.22)",
transform: "rotate(-4deg)",
},
{ left: "17%", top: "21%", width: "22%", height: "3%", background: "#292524", transform: "rotate(-4deg)" },
{ left: "17%", top: "28%", width: "28%", height: "1.6%", background: "#a8a29e", transform: "rotate(-4deg)" },
{
left: "52%",
top: "36%",
width: "30%",
height: "40%",
background: "linear-gradient(160deg,#f59e0b,#b45309)",
boxShadow: "0 14px 26px rgba(120,53,15,0.35)",
transform: "rotate(6deg)",
},
{
left: "16%",
top: "60%",
width: "28%",
height: "22%",
background: "#292524",
boxShadow: "0 12px 22px rgba(0,0,0,0.3)",
},
{ left: "20%", top: "64%", width: "12%", height: "2%", background: "#fbbf24" },
],
// 04 海へ開くテラス
[
{ inset: 0, background: "linear-gradient(180deg,#fde9c8 0%,#fcd9a0 26%,#f6c37a 36%)" },
{
inset: 0,
background: "radial-gradient(circle at 50% 36%, #fff6df 0 3.5%, rgba(251,191,36,0.55) 3.6% 7%, rgba(251,191,36,0) 20%)",
},
{ left: 0, right: 0, top: "36%", bottom: 0, background: "linear-gradient(180deg,#8a7f78 0%,#5c5550 100%)" },
{
left: 0,
right: 0,
top: "36%",
bottom: 0,
background: "repeating-linear-gradient(180deg, rgba(255,240,210,0.22) 0 1px, rgba(255,255,255,0) 1px 11px)",
},
{
left: "44%",
width: "12%",
top: "36%",
height: "30%",
background: "linear-gradient(180deg, rgba(255,214,140,0.85), rgba(255,214,140,0))",
},
{
left: "-10%",
right: "-10%",
top: "66%",
bottom: 0,
background: "repeating-linear-gradient(90deg,#3b2f28 0 22px,#4a3b31 22px 24px)",
clipPath: "polygon(18% 0, 82% 0, 100% 100%, 0 100%)",
},
{ left: 0, right: 0, top: "60%", height: "1.2%", background: "#1c1917" },
{
left: 0,
right: 0,
top: "60%",
height: "8%",
background: "repeating-linear-gradient(90deg,#1c1917 0 3px,rgba(28,25,23,0) 3px 38px)",
},
],
// 05 夜の工場
[
{ inset: 0, background: "linear-gradient(180deg,#0f1424 0%,#1f2236 46%,#4a2f2a 72%,#7c3f1f 80%)" },
{
left: 0,
right: 0,
top: 0,
height: "56%",
background: "radial-gradient(circle, rgba(254,243,199,0.75) 0 1px, rgba(254,243,199,0) 1.2px) 0 0/29px 31px",
},
{ inset: 0, background: "radial-gradient(circle at 24% 18%, #fef3c7 0 3%, rgba(254,243,199,0.18) 3.2% 9%, transparent 9%)" },
{
left: "-4%",
right: "30%",
top: "34%",
bottom: 0,
background: "#0b0a0c",
clipPath:
"polygon(0 34%, 14% 34%, 14% 4%, 20% 4%, 20% 34%, 40% 34%, 40% 14%, 46% 14%, 46% 34%, 70% 18%, 100% 30%, 100% 100%, 0 100%)",
},
{
left: "6%",
right: "40%",
top: "56%",
bottom: "10%",
background: "radial-gradient(rgba(251,191,36,0.95) 0 2px, transparent 2.6px) 0 0/15px 17px",
},
{
left: "52%",
right: "-4%",
top: "54%",
bottom: 0,
background: "#141114",
clipPath: "polygon(0 26%, 100% 6%, 100% 100%, 0 100%)",
},
{
left: "60%",
right: "6%",
top: "66%",
height: "2%",
background: "repeating-linear-gradient(90deg, #f59e0b 0 10px, rgba(245,158,11,0) 10px 22px)",
},
{
left: "8%",
top: "6%",
width: "16%",
height: "30%",
background: "radial-gradient(60% 50% at 50% 100%, rgba(214,211,209,0.28), rgba(214,211,209,0))",
},
],
// 06 広場を真上から
[
{ inset: 0, background: "#e7dfd3" },
{
inset: 0,
background:
"repeating-linear-gradient(0deg, rgba(120,100,80,0.14) 0 1px, rgba(0,0,0,0) 1px 22px), repeating-linear-gradient(90deg, rgba(120,100,80,0.14) 0 1px, rgba(0,0,0,0) 1px 22px)",
},
{
left: "-10%",
right: "-10%",
top: "46%",
height: "9%",
background: "linear-gradient(90deg,#d97706,#f59e0b)",
transform: "rotate(-8deg)",
},
{
left: "36%",
top: "22%",
width: "28%",
aspectRatio: "1",
borderRadius: "50%",
background: "radial-gradient(circle, #f5efe6 0 30%, #cfc4b4 30% 34%, #e7dfd3 34%)",
boxShadow: "inset 0 0 0 2px rgba(120,100,80,0.25)",
},
...[
["10%", "12%"],
["76%", "10%"],
["14%", "68%"],
["78%", "70%"],
].map(([left, top]) => ({
left,
top,
width: "13%",
aspectRatio: "1",
borderRadius: "50%",
background: "radial-gradient(circle at 40% 36%, #8a9a6a 0 30%, #5d6b45 70%)",
boxShadow: "10px 12px 0 rgba(28,25,23,0.22)",
})),
],
];
/** 全カット共通の粒子と光。マスクの内側だが画とは一緒に動かさない(動いているのは覆いだけに見せる) */
const grain: CSSProperties = {
inset: 0,
background:
"radial-gradient(120% 90% at 28% 18%, rgba(255,255,255,0.16), rgba(255,255,255,0) 55%), linear-gradient(180deg, rgba(28,25,23,0) 62%, rgba(28,25,23,0.2)), repeating-linear-gradient(45deg, rgba(28,25,23,0.045) 0 1px, rgba(28,25,23,0) 1px 6px)",
};
const clamp01 = (n: number) => (n < 0 ? 0 : n > 1 ? 1 : n);
/** インラインで渡す行内スタッガーの開始位置(0〜1のローカル進捗上の座標) */
const at = (s: number) => ({ "--s": s.toFixed(2) }) as CSSProperties;
function Shot({ v }: { v: number }) {
return (
<>
{shots[v].map((layer, i) => (
<span key={i} aria-hidden="true" className="absolute" style={layer} />
))}
</>
);
}
/** 覆い・マスク・境目の線を持つ1枚の枠。開き具合は祖先の --t が決める */
function Frame({ shot, dir, aspect }: { shot: number; dir: Dir; aspect: string }) {
return (
<div className={`relative overflow-hidden ${aspect}`}>
{/* 覆いの面。閉じている間だけ見え、開く向きを書いておく */}
<span aria-hidden="true" className="cwg-cover absolute inset-0 flex items-end p-3">
<span className="font-display text-[11px] font-semibold text-stone-500">
<span className="mr-1 text-amber-700">{DIRS[dir].arrow}</span>
{DIRS[dir].label}開く
</span>
</span>
<span className="cwg-mask absolute inset-0 block">
{/* 画は周囲12%ぶん大きく敷き、閉じ側へ寄せた位置から0へ戻す */}
<span className="cwg-shot absolute -inset-[12%] block">
<Shot v={shot} />
</span>
<span aria-hidden="true" className="absolute" style={grain} />
</span>
{/* マスクの境目を示す線(transform だけで動かす) */}
<span aria-hidden="true" className="cwg-edge pointer-events-none absolute inset-0" />
</div>
);
}
export default function ClipWipeGallery() {
const rootRef = useRef<HTMLElement>(null);
useEffect(() => {
const el = rootRef.current;
if (!el) return;
// reduced-motion: 開き切った状態を CSS 側(--p: 1 !important)が固定するので、
// JS は行の見出しを 100% にそろえるだけで、リスナーを一切張らない。
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
el.querySelectorAll("[data-cwg-pct]").forEach((out) => (out.textContent = "100%"));
return;
}
let rafId = 0;
let visible = true;
// 進捗は「行・タイルそれぞれが自分の位置で測る」。セクション1本の進捗で全部を駆動すると、
// 縦に長い節では下の行が画面へ入る前に開き切ってしまう(節の高さと行の到達時刻が比例しない)。
const nodes = Array.from(el.querySelectorAll<HTMLElement>(".cwg-t"));
// 行の見出しに出す「何%開いたか」。CSS の --w と同じ値で換算する
const w = parseFloat(getComputedStyle(el).getPropertyValue("--w")) || 0.75;
const readouts = nodes.map((n) => n.querySelector<HTMLElement>(":scope > [data-cwg-row] [data-cwg-pct]"));
const update = () => {
rafId = 0;
const vh = window.innerHeight || 1;
nodes.forEach((n, i) => {
const rect = n.getBoundingClientRect();
// 上端がビューポートの下端を切ってから min(自分の高さ, 60vh) ぶん進む間で 0 から 1 へ。
// 開き始めを画面の下端に置くので、最初の画面に入っている1枚目は読み込んだ時点で開いている。
// 分母に要素自身の高さを混ぜてあるので、縮小プレビューのように小さく描画されても最後まで到達する。
const span = Math.max(1, Math.min(rect.height, vh * 0.6));
const p = clamp01((vh - rect.top) / span);
n.style.setProperty("--p", p.toFixed(4));
const out = readouts[i];
if (out) {
const pct = `${Math.round(clamp01(p / w) * 100)}%`;
if (out.textContent !== pct) out.textContent = pct;
}
});
};
// rAF で1フレーム1回に合体させる(scroll は passive)
const onScroll = () => {
if (!visible || rafId) return;
rafId = requestAnimationFrame(update);
};
// 画面外では計測そのものを止める(出入りの瞬間には必ず1回そろえる)
const io =
typeof IntersectionObserver !== "undefined"
? new IntersectionObserver(
(es) => {
visible = es.some((e) => e.isIntersecting);
update();
},
{ rootMargin: "35% 0px" },
)
: null;
io?.observe(el);
update();
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onScroll, { passive: true });
return () => {
io?.disconnect();
window.removeEventListener("scroll", onScroll);
window.removeEventListener("resize", onScroll);
if (rafId) cancelAnimationFrame(rafId);
};
}, []);
return (
<section
ref={rootRef}
aria-labelledby="cwg-heading"
className="cwg w-full max-w-6xl bg-white px-1"
>
{/* 台帳の罫: 英字キッカーを置かず、標本番号と点数だけの1行にする */}
<div className="flex items-baseline justify-between gap-4 border-b border-gray-200 pb-3">
<p className="font-display text-[11px] font-semibold tracking-wide text-gray-500">
BLK-59
<span aria-hidden="true" className="mx-2 text-gray-300">
/
</span>
<span className="font-sans font-bold text-gray-700">実績・事例</span>
<span aria-hidden="true" className="mx-2 text-gray-300">
/
</span>
<span className="font-sans font-medium text-gray-400">撮り下ろし</span>
</p>
<p className="font-display text-[11px] font-semibold tabular-nums text-gray-400">
{works.length} 点
</p>
</div>
{/* 見出しは動かさない。この節で動くのは覆いだけ、という構えを崩さないため */}
<header className="mt-5 max-w-2xl sm:mt-8">
<h2
id="cwg-heading"
className="text-[clamp(1.45rem,4vw,2.4rem)] leading-[1.32] font-bold tracking-tight text-gray-900"
>
スクロールした
<span className="relative whitespace-nowrap">
ぶんだけ
<span aria-hidden="true" className="absolute -bottom-1 left-0 h-[3px] w-full bg-amber-500/70" />
</span>
、<span className="whitespace-nowrap">現場が開いていく</span>
</h2>
{/* 和文の段落はソース上でも改行しない(折ると「、 読」のように句読点の後だけ空く) */}
<p className="mt-3 text-[14px] leading-[1.85] font-medium text-gray-600 sm:mt-5 sm:text-[15px]">
写真は浮かび上がるのではなく、覆いが引かれて現れます。行ごとに開く向きを変えました。
</p>
</header>
{/* 状態見本: スクロールを始める前に、開き方と戻り方をここで見せる */}
<div className="mt-5 sm:mt-7">
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 text-[12px] font-semibold text-gray-700">
<p>
スクロールで開く<span className="mx-1.5 text-gray-300">・</span>戻すと閉じる
</p>
<p className="flex gap-1.5 text-[11px]">
{(Object.keys(DIRS) as Dir[]).map((d) => (
<a
key={d}
href="#cwg-edit-dir"
className="border border-gray-200 px-2 py-1 text-gray-600 hover:border-amber-600 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600"
>
<span aria-hidden="true" className="mr-1 text-amber-700">
{DIRS[d].arrow}
</span>
{DIRS[d].label}
</a>
))}
</p>
</div>
<ol className="cwg-l mt-3 grid list-none grid-cols-3 gap-2 sm:gap-4" aria-label="同じ写真の開き具合">
{SAMPLES.map((s) => (
<li key={s.label} style={{ "--t": s.t } as CSSProperties}>
<Frame shot={0} dir="l" aspect="aspect-[4/3]" />
<p className="mt-2 flex items-baseline justify-between gap-2 text-[11px] font-semibold text-gray-700">
{s.label}
<span className="font-display tabular-nums text-amber-700">{Math.round(s.t * 100)}%</span>
</p>
<span aria-hidden="true" className="mt-1 block h-[2px] bg-gray-200">
<span className="block h-full bg-amber-600" style={{ width: `${s.t * 100}%` }} />
</span>
</li>
))}
</ol>
</div>
{rows.map((row, r) => (
<div key={r} className={`cwg-t cwg-${row.dir} mt-9 sm:mt-14`}>
{/* 行の見出し: 開く向きと、その行が何%開いたか。罫線は開く向きへ引かれる(transform: scaleX のみ) */}
<div data-cwg-row className="flex items-center gap-3">
<p className="shrink-0 text-[11px] font-semibold text-gray-500">
<span aria-hidden="true" className="mr-1 text-amber-700">
{DIRS[row.dir].arrow}
</span>
{DIRS[row.dir].label}開く
<span aria-hidden="true" data-cwg-pct className="ml-2 inline-block w-[4ch] font-display tabular-nums text-gray-400">
0%
</span>
</p>
<span aria-hidden="true" className="cwg-rule block h-px flex-1 bg-gray-300" />
</div>
<ul className={`mt-4 grid list-none grid-cols-1 gap-x-6 gap-y-7 sm:mt-6 sm:gap-y-12 ${row.cols}`}>
{row.items.map((wi, i) => {
const w = works[wi];
return (
<li key={w.no} className="cwg-t" style={at(i * STAGGER)}>
{/* clip-path をかけるのは <a> の内側だけ。フォーカスリングが切られないようにする */}
<a
href="#"
className="group block focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-amber-600"
>
<Frame shot={w.shot} dir={row.dir} aspect={w.aspect} />
<div className="relative mt-3 pt-3 sm:mt-4 sm:pt-4">
<span aria-hidden="true" className="absolute inset-x-0 top-0 h-px bg-gray-200" />
<span
aria-hidden="true"
className="absolute inset-x-0 top-0 h-px origin-left scale-x-0 bg-amber-600 transition-transform duration-500 ease-out group-hover:scale-x-100 motion-reduce:transition-none"
/>
{/* キャプションは画と逆向きに開く */}
<div className="cwg-cap">
<div className="flex items-baseline gap-3">
<span className="font-display text-[11px] font-bold tabular-nums text-amber-700">
{w.no}
</span>
<h3 className="text-[15px] leading-[1.6] font-bold tracking-tight text-gray-900">
{w.title}
</h3>
</div>
<p className="mt-1.5 text-[11px] font-medium text-gray-400 sm:mt-2">
{w.field}
<span aria-hidden="true" className="mx-1.5 text-gray-300">
/
</span>
<span className="font-display tabular-nums">{w.year}</span>
</p>
</div>
</div>
</a>
</li>
);
})}
</ul>
</div>
))}
<div className="mt-12 flex flex-wrap items-baseline justify-between gap-4 border-t border-gray-200 pt-6 sm:mt-16">
<p className="font-display text-[11px] font-semibold tabular-nums text-gray-400">
2025
<span aria-hidden="true" className="mx-1.5 text-gray-300">
—
</span>
2026
<span aria-hidden="true" className="mx-2 text-gray-300">
/
</span>
<span className="font-sans font-medium">撮り下ろし {works.length} 点</span>
</p>
<a
href="#"
className="group inline-flex items-center text-sm font-semibold text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-amber-600"
>
<span className="relative">
実績の一覧を見る
<span className="absolute -bottom-1 left-0 h-px w-full origin-left scale-x-100 bg-gray-900 transition-transform duration-300 ease-out group-hover:scale-x-0 motion-reduce:transition-none" />
<span className="absolute -bottom-1 left-0 h-px w-full origin-right scale-x-0 bg-amber-600 transition-transform delay-150 duration-300 ease-out group-hover:origin-left group-hover:scale-x-100 motion-reduce:transition-none" />
</span>
</a>
</div>
{/* 転用の手引き: 案件で変える所だけを、このファイルの中の名前で示す */}
<footer id="cwg-edit" className="mt-12 border-t border-gray-200 pt-6 text-[12px] leading-[1.8] text-gray-600">
<p className="font-semibold text-gray-900">案件へ持ち込むときに変える所</p>
<pre className="mt-3 overflow-x-auto border border-gray-200 bg-stone-50 p-3 font-mono text-[11px] leading-[1.7] text-gray-800">
{`// 置きたいページで読み込むだけ(props なし・依存ライブラリなし)
<ClipWipeGallery />`}
</pre>
<dl className="mt-4 grid gap-x-6 gap-y-3 sm:grid-cols-[9rem_1fr]">
<dt className="font-semibold text-gray-800">写真の差し替え</dt>
<dd>
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">works</code> の見出し・業種・年を書き換える。写真を使うなら{" "}
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">{"<Shot />"}</code> を{" "}
<code className="font-mono text-[11px] break-all text-amber-800">{'<img className="h-full w-full object-cover" />'}</code>{" "}
に替える(周囲12%大きく敷く枠はそのまま使う)
</dd>
<dt id="cwg-edit-dir" className="font-semibold text-gray-800">
開く向き
</dt>
<dd>
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">rows</code> の{" "}
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">dir</code> を{" "}
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">"l"</code>(左から)・
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">"d"</code>(上から)・
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">"r"</code>(右から)にする
</dd>
<dt className="font-semibold text-gray-800">ずらし幅と速さ</dt>
<dd>
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">STAGGER</code>(行内で1枚ごとの遅れ。0 で同時)と、
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">{"<style>"}</code> の{" "}
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">.cwg {"{ --w }"}</code>(1枚が開き切るまでの長さ。小さいほど速い)
</dd>
<dt className="font-semibold text-gray-800">狭い画面の並び順</dt>
<dd>
640px未満は1列で <code className="font-mono text-[11px] whitespace-nowrap text-amber-800">items</code> の順に積む。順を変えるなら{" "}
<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">items</code> を入れ替えるか、<code className="font-mono text-[11px] whitespace-nowrap text-amber-800">li</code>{" "}
に <code className="font-mono text-[11px] whitespace-nowrap text-amber-800">order-2 sm:order-none</code> を付ける
</dd>
<dt className="font-semibold text-gray-800">動きを減らす設定</dt>
<dd>OS の「動きを減らす」設定(prefers-reduced-motion: reduce)が有効なら、全タイルを最初から全開で固定する(開き具合は CSS が固定し、行見出しの % 表示だけ JS で 100% にそろえる。JS を省くなら % 表示も外す)</dd>
</dl>
<p className="mt-5 font-semibold text-gray-800">根拠にした仕様(2026-11-16 確認)</p>
<ul className="mt-1 space-y-1">
{SOURCES.map((source) => (
<li key={source.href}>
<a
href={source.href}
target="_blank"
rel="noopener noreferrer"
className="underline decoration-gray-300 underline-offset-4 hover:decoration-gray-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-700"
>
{source.label}
</a>
: {source.note}
</li>
))}
</ul>
<p className="mt-2 text-gray-500">事例名・業種・年は架空の表示サンプルです。写真はCSSの図形で描いています。</p>
</footer>
{/* スクロール進捗からローカル進捗、そしてマスクへの換算はすべてここ(JSは --p を書くだけ) */}
<style>{`
.cwg { --w: 0.75; }
.cwg-t { --p: 0; --t: clamp(0, (var(--p) - var(--s, 0)) / var(--w), 1); }
/* キーボードで到達したタイルは必ず開き切る(:focus-within のほうが詳細度が高い) */
.cwg-t:focus-within { --t: 1; }
.cwg-cover {
background:
repeating-linear-gradient(135deg, rgba(120,113,108,0.12) 0 1px, rgba(0,0,0,0) 1px 7px),
linear-gradient(180deg, #f1ede7, #e7e2da);
}
.cwg-mask, .cwg-cap { will-change: clip-path; }
.cwg-l .cwg-mask { clip-path: inset(0 calc((1 - var(--t)) * 100%) 0 0); }
.cwg-r .cwg-mask { clip-path: inset(0 0 0 calc((1 - var(--t)) * 100%)); }
.cwg-d .cwg-mask { clip-path: inset(0 0 calc((1 - var(--t)) * 100%) 0); }
.cwg-shot { will-change: transform; }
.cwg-l .cwg-shot { transform: translateX(calc((1 - var(--t)) * 9%)); }
.cwg-r .cwg-shot { transform: translateX(calc((1 - var(--t)) * -9%)); }
.cwg-d .cwg-shot { transform: translateY(calc((1 - var(--t)) * 9%)); }
/* 境目の線: 枠いっぱいの面の1辺に線を引き、その面ごと --t ぶん送る。開き切る前後は消す */
.cwg-edge { will-change: transform; opacity: clamp(0, min(var(--t), 1 - var(--t)) * 30, 1); }
.cwg-l .cwg-edge { border-left: 2px solid #d97706; transform: translateX(calc(var(--t) * 100% - 1px)); }
.cwg-r .cwg-edge { border-right: 2px solid #d97706; transform: translateX(calc(var(--t) * -100% + 1px)); }
.cwg-d .cwg-edge { border-top: 2px solid #d97706; transform: translateY(calc(var(--t) * 100% - 1px)); }
.cwg-l .cwg-cap { clip-path: inset(0 0 0 calc((1 - var(--t)) * 100%)); }
.cwg-r .cwg-cap { clip-path: inset(0 calc((1 - var(--t)) * 100%) 0 0); }
.cwg-d .cwg-cap { clip-path: inset(0 calc((1 - var(--t)) * 100%) 0 0); }
.cwg-rule { transform: scaleX(var(--t)); }
.cwg-l .cwg-rule { transform-origin: left center; }
.cwg-r .cwg-rule { transform-origin: right center; }
.cwg-d .cwg-rule { transform-origin: center center; }
@media (prefers-reduced-motion: reduce) {
.cwg-t { --p: 1 !important; }
}
`}</style>
</section>
);
}
Add to your project via shadcn CLI
npx shadcn@latest add https://designs.first-ch.com/r/clip-wipe-gallery.json