Fix folder stack overlap: pull slots, split tab/body sticky.

Sections overlap via negative margin; tabs stay in staggered rail;
active body z-index covers layers below as you scroll.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-20 23:05:20 -04:00
co-authored by Cursor
parent acfc6ddd86
commit bb8469ca10
10 changed files with 720 additions and 246 deletions
+11 -2
View File
@@ -5,12 +5,13 @@ export function initStackScroll(options = {}) {
depthEl = document.getElementById('depth'),
depthPrefix = 'L',
tabSelector = '[data-goto], .jump',
bodySelector = '.body, .layer-inner, .frame-body, .unit-body',
} = options;
const sections = document.querySelectorAll(sectionSelector);
if (!sections.length) return;
const mid = () => window.innerHeight * 0.4;
const mid = () => window.innerHeight * 0.42;
function updateDepth() {
let active = 0;
@@ -19,11 +20,19 @@ export function initStackScroll(options = {}) {
if (r.top <= mid() && r.bottom > mid()) active = Number(sec.dataset.layer);
});
if (depthEl) depthEl.textContent = `${depthPrefix}${active}`;
document.querySelectorAll('.stack-ruler button, .stack-ruler [data-goto], .tab-rail button, .tab[data-goto]').forEach((el) => {
const n = el.dataset.layer ?? el.dataset.goto;
if (n === undefined) return;
el.classList.toggle('active', Number(n) === active);
});
sections.forEach((sec) => {
const layer = Number(sec.dataset.layer);
const body = sec.querySelector(bodySelector);
if (!body) return;
body.style.zIndex = layer === active ? 100 : 10 + layer;
});
}
document.querySelectorAll(tabSelector).forEach((tab) => {
@@ -32,7 +41,7 @@ export function initStackScroll(options = {}) {
const layer = tab.dataset.goto;
const target = document.querySelector(`${sectionSelector}[data-layer="${layer}"]`);
if (!target) return;
const y = target.offsetTop - 48;
const y = target.getBoundingClientRect().top + window.scrollY - 48;
window.scrollTo({ top: Math.max(0, y), behavior: 'smooth' });
});
});