-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsite.js
More file actions
43 lines (38 loc) · 1.42 KB
/
Copy pathsite.js
File metadata and controls
43 lines (38 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Scroll progress bar + scroll-reveal — progressive enhancement; the page
stays fully visible when JS is disabled. */
(function () {
var reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
/* ---- scroll progress ---- */
var bar = document.querySelector(".scroll-progress");
if (bar && !reduced) {
var ticking = false;
function update() {
var h = document.documentElement;
var max = h.scrollHeight - h.clientHeight;
bar.style.setProperty("--p", max > 0 ? (h.scrollTop / max) : 0);
ticking = false;
}
window.addEventListener("scroll", function () {
if (!ticking) { requestAnimationFrame(update); ticking = true; }
}, { passive: true });
update();
}
/* ---- scroll reveal with a light stagger ---- */
var targets = document.querySelectorAll(
"section > h2, .skill-card, .release, .plain-card, .note-item"
);
if (reduced || !("IntersectionObserver" in window)) return;
targets.forEach(function (el, i) {
el.classList.add("reveal");
el.style.transitionDelay = Math.min((i % 6) * 45, 180) + "ms";
});
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add("in");
io.unobserve(entry.target);
}
});
}, { threshold: 0.1, rootMargin: "0px 0px -6% 0px" });
targets.forEach(function (el) { io.observe(el); });
})();