-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (60 loc) · 3.16 KB
/
index.js
File metadata and controls
65 lines (60 loc) · 3.16 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
document.addEventListener('DOMContentLoaded', function () {
// Header scroll effect
const header = document.getElementById('page-header');
if (header) {
const handleScroll = () => {
if (window.scrollY > 10) {
header.classList.add('bg-white/80', 'backdrop-blur-lg', 'shadow-md', 'border-slate-200');
header.classList.remove('bg-transparent', 'border-transparent');
} else {
header.classList.remove('bg-white/80', 'backdrop-blur-lg', 'shadow-md', 'border-slate-200');
header.classList.add('bg-transparent', 'border-transparent');
}
};
window.addEventListener('scroll', handleScroll);
handleScroll(); // Initial check
}
// Mobile menu toggle
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
const iconBars = document.getElementById('icon-bars');
const iconXMark = document.getElementById('icon-xmark');
if (mobileMenuButton && mobileMenu && iconBars && iconXMark) {
mobileMenuButton.addEventListener('click', () => {
const isExpanded = mobileMenuButton.getAttribute('aria-expanded') === 'true' || false;
mobileMenuButton.setAttribute('aria-expanded', !isExpanded);
mobileMenu.classList.toggle('hidden');
iconBars.classList.toggle('hidden');
iconXMark.classList.toggle('hidden');
});
// Close mobile menu on link click
const mobileMenuLinks = mobileMenu.querySelectorAll('.mobile-menu-link');
mobileMenuLinks.forEach(link => {
link.addEventListener('click', () => {
mobileMenuButton.setAttribute('aria-expanded', 'false');
mobileMenu.classList.add('hidden');
iconBars.classList.remove('hidden');
iconXMark.classList.add('hidden');
});
});
}
// HeroSection "Learn More" smooth scroll
const learnMoreButton = document.getElementById('learn-more-button');
if (learnMoreButton) {
learnMoreButton.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1); // Get 'how-it-works'
const targetElement = document.getElementById(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
}
});
}
// Set current year in footer
const yearSpan = document.getElementById('currentYear');
if (yearSpan) {
yearSpan.textContent = new Date().getFullYear();
}
});