Introduction
Start with the story. A reading indicator tells the reader how much is left.
8 scroll patterns
Explore each pattern in its own viewport. Scroll by hand or play the demo.
Scroll the article and watch the chapter label and progress line.
Start with the story. A reading indicator tells the reader how much is left.
Give long pages short chapters and meaningful headings.
Keep progress pegged to the article when the page has other sections.
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.reading-track { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; min-height: 31px; background: var(--ink); color: var(--canvas); font: 500 .69rem var(--mono); }
.reading-track::after { content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; transform: scaleX(var(--p)); transform-origin: left; background: var(--cyan); }
.reading-chapter { min-height: 117px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.reading-chapter + .reading-chapter { background: var(--canvas); }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Build a scroll-local reading indicator. Divide scrollTop by the available scroll distance, drive a sticky bar with scaleX, and announce chapter boundaries without narrating every pixel.Scroll down to open the curtains around the card.
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.curtain-story { height: 410px; }
.curtain-pin { position: sticky; top: 0; height: 174px; display: grid; place-items: center; background: #202020; color: var(--canvas); padding: 12px; }
.curtain-card { width: min(85%,300px); height: 116px; display: grid; place-items: center; background: #d3e5ff; color: #172241; border-radius: 8px; clip-path: inset(0 calc(40% * (1 - var(--p))) 0 calc(40% * (1 - var(--p))) round 8px); }
.curtain-card span { font: 600 clamp(1.1rem,4vw,1.75rem) var(--font); letter-spacing: -.05em; }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Pin a specimen and reveal it from the center with clip-path inset. Normalize scroll progress, reserve the full frame size, and show the whole specimen when reduced motion is enabled.The subject stays pinned while the story advances beside it.
Subject stays here
Anchor the subject first.
Advance the narrative beside it.
Let the subject leave at the end.
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.split-story { display: grid; grid-template-columns: 44% 56%; background: var(--canvas); }
.split-pin { position: sticky; top: 0; height: 174px; display: grid; place-content: center; padding: 12px; background: var(--ink); color: var(--canvas); }
.split-pin p { color: #d3d3d3; font: 400 .7rem var(--mono); }
.split-story article { min-height: 118px; padding: 12px; border-bottom: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Build a two-column scrollytelling layout with a sticky, viewport-sized subject and normal-flow story panels. Keep source and keyboard order logical and avoid global scroll interception.Scroll vertically to scrub the card track sideways.
01
02
03
04
05
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.horizontal-story { height: 435px; }
.horizontal-pin { display: flex; align-items: center; height: 174px; overflow: clip; position: sticky; top: 0; }
.horizontal-track { display: flex; gap: 8px; padding-inline: 10px; transform: translateX(calc(var(--p) * var(--track-travel,0px) * -1)); }
.horizontal-track article { width: 148px; height: 110px; display: grid; align-content: end; border-radius: 8px; padding: 10px; background: var(--canvas); box-shadow: var(--shadow); }
.horizontal-track article:nth-child(even) { background: #d3e5ff; }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Map local vertical progress to horizontal translateX. Measure the track overflow instead of assuming a card width. Use a sticky viewport and retain a manual scrolling path.Scroll to move foreground, backdrop, and label at different rates.
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.parallax-story { height: 410px; }
.parallax-pin { position: sticky; top: 0; height: 174px; isolation: isolate; overflow: hidden; display: grid; place-items: center; background: #171717; color: var(--canvas); }
.parallax-pin i { position: absolute; inset: 0; z-index: -2; background: #4c2889; clip-path: polygon(0 45%,28% 29%,51% 52%,77% 26%,100% 45%,100% 100%,0 100%); transform: translateY(calc(var(--p) * -30px)); }
.parallax-pin i:nth-child(2) { z-index: -1; background: #7928ca; clip-path: polygon(0 78%,30% 54%,49% 70%,73% 52%,100% 73%,100% 100%,0 100%); transform: translateY(calc(var(--p) * -18px)); }
.parallax-pin h3 { transform: translateY(calc(var(--p) * -7px)); }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Create a pinned depth band with two layers and a fixed-size viewport. Drive each layer at a different speed from one normalized scroll value. Freeze decorative movement with reduced motion.Scroll to scale the headline inside the fixed frame.
Scale follows scroll position
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.kinetic-story { height: 420px; }
.kinetic-pin { position: sticky; top: 0; height: 174px; overflow: clip; display: grid; align-content: center; justify-items: center; background: #d3e5ff; }
.kinetic-pin h3 { font-size: clamp(1.25rem,5vw,2.3rem); letter-spacing: -.06em; transform: scale(calc(1 + var(--p) * .65)); transform-origin: center; }
.kinetic-pin p { margin-top: 16px; font: 400 .7rem var(--mono); }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Scale a centered headline from 1 to 1.65 with local scroll progress. Reserve enough space at the final scale. Keep the text readable and remove scaling for reduced motion.Scroll to pile three cards with staggered sticky offsets.
Anchor the subject first.
Advance the narrative beside it.
Let the subject leave at the end.
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.stacking-story { padding: 8px 12px 75px; }
.stacking-story article { position: sticky; top: var(--stack-top); margin-bottom: 32px; min-height: 99px; padding: 12px; border-radius: 8px; box-shadow: var(--shadow); background: var(--canvas); }
.stacking-story article:nth-child(2) { background: #d3e5ff; }
.stacking-story article:nth-child(3) { background: #d8ccf1; }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Stack cards using position: sticky and distinct top offsets. Keep the document order and make the final card readable on narrow screens. Add enough end space for the stack to form.Swipe sideways, use arrow keys, or run the auto-scroll demo.
Slide 1 of 5
Slide 2 of 5
Slide 3 of 5
Slide 4 of 5
Slide 5 of 5
.scroll-toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); border-radius: 7px 7px 0 0; }
.scroll-progress { color: var(--body); padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 500 .67rem var(--mono); }
.scroll-frame { position: relative; height: 174px; overflow: auto; overscroll-behavior: contain; isolation: isolate; color: var(--ink); border-radius: 0 0 7px 7px; --p: 0; }
.scroll-frame:focus-visible { outline-offset: -3px; }
.scroll-frame article,.scroll-frame section { font-size: .84rem; }
.scroll-frame h3 { font-size: 1.18rem; }
.scroll-frame.snap-frame { display: flex; gap: 8px; padding: 10px; scroll-snap-type: x mandatory; scroll-padding-inline: 10px; }
.snap-frame article { display: grid; align-content: end; flex: 0 0 min(76%,340px); background: var(--canvas); box-shadow: var(--shadow); padding: 14px; border-radius: 8px; scroll-snap-align: start; }
.snap-frame article:nth-child(2n) { background: #d3e5ff; }
.snap-frame[data-playing] { scroll-snap-type: none; }
@media (prefers-reduced-motion: reduce) {
.parallax-pin i,.parallax-pin h3,.kinetic-pin h3 { transform: none; }
.curtain-card { clip-path: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: .001ms;
transition-duration: .001ms;
}
}for (const frame of document.querySelectorAll('.scroll-frame')) {
const viewport = frame.closest('.lab-demo');
const button = viewport.querySelector('[data-auto-scroll]');
const output = viewport.querySelector('.scroll-progress');
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const horizontal = frame.classList.contains('snap-frame');
const axis = horizontal ? 'scrollLeft' : 'scrollTop';
const max = () => horizontal ? frame.scrollWidth - frame.clientWidth : frame.scrollHeight - frame.clientHeight;
const track = frame.querySelector('.horizontal-track');
const chapter = frame.querySelector('[data-chapter]');
const captions = ['Introduction', 'Structure', 'Conclusion'];
let animation = 0;
let lastProgress = -1;
function update() {
const progress = Math.max(0, Math.min(1, frame[axis] / Math.max(1, max())));
frame.style.setProperty('--p', progress.toFixed(4));
if (track) {
const travel = Math.max(0, track.scrollWidth - frame.clientWidth);
frame.style.setProperty('--track-travel', travel + 'px');
}
const percent = Math.round(progress * 100);
if (percent !== lastProgress) {
output.textContent = percent + '%';
lastProgress = percent;
}
if (chapter) chapter.textContent = captions[Math.min(2, Math.floor(progress * 3))];
}
function stop() {
cancelAnimationFrame(animation);
animation = 0;
delete frame.dataset.playing;
button.textContent = 'Auto-scroll demo';
button.setAttribute('aria-pressed', 'false');
}
button.addEventListener('click', () => {
if (animation) {
stop();
return;
}
if (reduced.matches) {
frame[axis] = frame[axis] >= max() - 1 ? 0 : max();
update();
return;
}
frame.dataset.playing = '';
frame[axis] = 0;
const start = performance.now();
const duration = 3000;
button.textContent = 'Pause demo';
button.setAttribute('aria-pressed', 'true');
const tick = (time) => {
const elapsed = Math.min(1, (time - start) / duration);
frame[axis] = Math.round(max() * elapsed);
if (elapsed < 1) animation = requestAnimationFrame(tick);
else stop();
};
animation = requestAnimationFrame(tick);
});
frame.addEventListener('scroll', update, { passive: true });
frame.addEventListener('wheel', stop, { passive: true });
frame.addEventListener('pointerdown', stop);
frame.addEventListener('focus', stop);
frame.addEventListener('keydown', stop);
reduced.addEventListener('change', stop);
new ResizeObserver(update).observe(frame);
update();
}Create a tactile CSS scroll-snap carousel. Use mandatory x snapping and inline scroll padding, preserve native touch/keyboard scrolling, and temporarily disable snap during programmatic playback.