-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (23 loc) · 843 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (23 loc) · 843 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
28
// Single scroll treatment: elements marked .reveal fade and rise into place.
// Fully disabled when the user prefers reduced motion.
(function () {
var reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
var items = document.querySelectorAll(".reveal");
if (reduced || !("IntersectionObserver" in window)) {
items.forEach(function (el) { el.classList.add("is-visible"); });
return;
}
document.documentElement.classList.add("js-reveal");
var observer = new IntersectionObserver(
function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.12 }
);
items.forEach(function (el) { observer.observe(el); });
})();