iqon/script.js
2026-03-01 01:03:18 +03:00

41 lines
1000 B
JavaScript

const reveals = document.querySelectorAll(".reveal");
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("on");
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.18 }
);
reveals.forEach((item, idx) => {
item.style.transitionDelay = `${Math.min(idx * 45, 280)}ms`;
observer.observe(item);
});
const navLinks = document.querySelectorAll(".main-nav a");
const sectionObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
navLinks.forEach((link) => {
link.classList.toggle("active", link.getAttribute("href") === `#${entry.target.id}`);
});
}
});
},
{ threshold: 0.55 }
);
["approach", "services", "cases", "contacts"].forEach((id) => {
const section = document.getElementById(id);
if (section) {
sectionObserver.observe(section);
}
});