forked from AaqibhafeezKhan/GameChanger360
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (76 loc) · 2.67 KB
/
script.js
File metadata and controls
76 lines (76 loc) · 2.67 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
document.addEventListener("DOMContentLoaded", function() {
const menuBtn = document.querySelector(".mobile-menu-btn");
const navMenu = document.querySelector(".nav-menu");
menuBtn?.addEventListener("click", () => {
navMenu.classList.toggle("active");
const spans = menuBtn.querySelectorAll("span");
if (navMenu.classList.contains("active")) {
spans[0].style.transform = "rotate(45deg) translate(5px, 5px)";
spans[1].style.opacity = "0";
spans[2].style.transform = "rotate(-45deg) translate(7px, -7px)";
} else {
spans[0].style.transform = "";
spans[1].style.opacity = "1";
spans[2].style.transform = "";
}
});
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute("href"));
if (target) {
target.scrollIntoView({
behavior: "smooth",
block: "start"
});
navMenu.classList.remove("active");
}
});
});
const sections = document.querySelectorAll("section[id]");
const navLinks = document.querySelectorAll(".nav-menu a");
function highlightNavigation() {
const scrollPosition = window.scrollY;
sections.forEach((section) => {
const sectionTop = section.offsetTop - 100;
const sectionHeight = section.offsetHeight;
const sectionId = section.getAttribute("id");
if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
navLinks.forEach((link) => {
link.classList.remove("active");
if (link.getAttribute("href") === `#${sectionId}`) {
link.classList.add("active");
}
});
}
});
}
window.addEventListener("scroll", highlightNavigation);
const faders = document.querySelectorAll(".solution-card, .service-card, .industry-card, .about-card");
const appearOptions = {
threshold: 0.2,
rootMargin: "0px 0px -50px 0px"
};
const appearOnScroll = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (!entry.isIntersecting) return;
entry.target.classList.add("fade-in");
observer.unobserve(entry.target);
});
}, appearOptions);
faders.forEach((fader) => {
appearOnScroll.observe(fader);
});
const slides = document.querySelectorAll(".hero-slider .slide");
let currentSlide = 0;
function showSlide(index) {
slides.forEach((slide, i) => {
slide.classList.toggle("active", i === index);
});
}
function nextSlide() {
currentSlide = (currentSlide + 1) % slides.length;
showSlide(currentSlide);
}
setInterval(nextSlide, 5000);
});