Let path nodes dim as the spine retreats

Node state now mirrors the fill in both directions with a small deadband, so scrolling back up visibly unlights the stages instead of leaving them stuck on.
This commit is contained in:
yigid authored and Yigid BALABAN committed 2026-11-01 13:42:57 +03:00
1 parent 23a55ea711
commit a4e9bbc1ea
2 files changed
+14 -10

No files matched your search

+7 -5
View File
@@ -15,9 +15,10 @@
els.forEach(function (e) { io.observe(e); });
}
// The spine "draws" as you scroll. A stage's node lights up the moment the
// fill reaches it, so the line and the milestones move together. Nodes stay
// lit once reached: they mark completed stages, not current scroll position.
// The spine "draws" as you scroll. Nodes mirror the fill: a node lights when
// the fill reaches it and dims again if you scroll back above it, so the two
// always tell the same story. A 6px deadband keeps tiny scroll jitter from
// flickering the state.
var fill = document.getElementById("spineFill"),
sw = document.querySelector(".spine-wrap"),
stages = sw ? [].slice.call(sw.querySelectorAll(".stage")) : [],
@@ -37,9 +38,10 @@
var fillY = spineTop + p * spineH;
stages.forEach(function (stage) {
if (stage.classList.contains("lit")) return;
var nodeY = stage.getBoundingClientRect().top - r.top + 18; // node top (7) + radius (11)
if (fillY >= nodeY) stage.classList.add("lit");
var on = stage.classList.contains("lit");
var next = on ? fillY >= nodeY - 6 : fillY >= nodeY;
if (next !== on) stage.classList.toggle("lit", next);
});
}