Signed-off-by: Yigit BALABAN <balaban@yigid.dev>
This commit is contained in:
commit
2cfe29f197
24 files changed
+4940
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/* Shared page behaviour, ported from the original inline script.
|
||||
* The peacock marks are inlined at build time (see Mark.astro), so only the
|
||||
* scroll reveals and the path spine remain. */
|
||||
(function () {
|
||||
var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
|
||||
// scroll reveals
|
||||
var els = [].slice.call(document.querySelectorAll(".reveal"));
|
||||
if (reduce) {
|
||||
els.forEach(function (e) { e.classList.add("in"); });
|
||||
} else if ("IntersectionObserver" in window) {
|
||||
var io = new IntersectionObserver(function (en) {
|
||||
en.forEach(function (x) { if (x.isIntersecting) x.target.classList.add("in"); });
|
||||
}, { threshold: .15 });
|
||||
els.forEach(function (e) { io.observe(e); });
|
||||
}
|
||||
|
||||
// the spine "draws" as you scroll through the path
|
||||
var fill = document.getElementById("spineFill"),
|
||||
sw = document.querySelector(".spine-wrap"),
|
||||
tick = false;
|
||||
function spine() {
|
||||
tick = false;
|
||||
if (!fill || !sw) return;
|
||||
var r = sw.getBoundingClientRect();
|
||||
var p = (innerHeight * 0.5 - r.top) / r.height;
|
||||
fill.style.height = (Math.max(0, Math.min(1, p)) * 100) + "%";
|
||||
}
|
||||
if (fill && sw) {
|
||||
if (reduce) {
|
||||
fill.style.height = "100%";
|
||||
} else {
|
||||
var onsc = function () { if (!tick) { tick = true; requestAnimationFrame(spine); } };
|
||||
addEventListener("scroll", onsc, { passive: true });
|
||||
addEventListener("resize", onsc);
|
||||
spine();
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user