-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
24 lines (22 loc) · 749 Bytes
/
Copy pathmain.js
File metadata and controls
24 lines (22 loc) · 749 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
// Scroll-in reveal animation
const revealObs = new IntersectionObserver(function (entries) {
entries.forEach(function (e) {
if (e.isIntersecting) {
e.target.classList.add('visible');
revealObs.unobserve(e.target);
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.reveal').forEach(function (el) {
const rect = el.getBoundingClientRect();
if (rect.top < window.innerHeight && rect.bottom >= 0) {
setTimeout(function () { el.classList.add('visible'); }, 100);
} else {
revealObs.observe(el);
}
});
// Nav background on scroll
window.addEventListener('scroll', function () {
document.querySelector('nav').style.background =
window.scrollY > 60 ? 'rgba(9,21,37,0.98)' : 'rgba(9,21,37,0.92)';
});