levkin.ca/stack/stack.js
ilia cfca7aade8 Add Stack design — sticky scroll layers L0 through L6.
Services presented as a literal card stack with depth indicator and enriched sibling-site content.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-20 22:39:05 -04:00

25 lines
662 B
JavaScript

const layers = document.querySelectorAll('.layer');
const depthEl = document.getElementById('depth');
const rulerSpans = document.querySelectorAll('.stack-ruler span');
function updateDepth() {
const mid = window.innerHeight * 0.45;
let active = 0;
layers.forEach((layer) => {
const rect = layer.getBoundingClientRect();
if (rect.top <= mid && rect.bottom > mid) {
active = Number(layer.dataset.layer);
}
});
depthEl.textContent = `depth: L${active}`;
rulerSpans.forEach((span, i) => {
span.classList.toggle('active', i === active);
});
}
window.addEventListener('scroll', updateDepth, { passive: true });
updateDepth();