-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
27 lines (22 loc) · 764 Bytes
/
Copy pathmain.js
File metadata and controls
27 lines (22 loc) · 764 Bytes
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
(() => {
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const revealTargets = document.querySelectorAll(
".section-head, .project, .pillars li"
);
revealTargets.forEach((el) => el.classList.add("reveal"));
if (reduce || !("IntersectionObserver" in window)) {
revealTargets.forEach((el) => el.classList.add("is-visible"));
return;
}
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (!entry.isIntersecting) return;
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
});
},
{ threshold: 0.16, rootMargin: "0px 0px -8% 0px" }
);
revealTargets.forEach((el) => observer.observe(el));
})();