-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (40 loc) · 1.61 KB
/
script.js
File metadata and controls
45 lines (40 loc) · 1.61 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
// Smooth scroll for internal links
document.addEventListener('click', (e) => {
const a = e.target.closest('a[href^="#"]');
if (!a) return;
const id = a.getAttribute('href').slice(1);
const el = document.getElementById(id);
if (el) {
e.preventDefault();
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
history.replaceState(null, '', `#${id}`);
// Close mobile menu after click
const mobile = document.getElementById('mobile-menu');
if (mobile && !mobile.hidden) toggleMobileMenu(false);
}
});
// Current year in footer
document.getElementById('year').textContent = new Date().getFullYear();
// Mobile menu toggle
const toggleBtn = document.querySelector('.nav-toggle');
const mobileMenu = document.getElementById('mobile-menu');
function toggleMobileMenu(forceClose){
const expanded = forceClose ? false : toggleBtn.getAttribute('aria-expanded') !== 'true';
toggleBtn.setAttribute('aria-expanded', expanded);
mobileMenu.hidden = !expanded;
}
if (toggleBtn){
toggleBtn.addEventListener('click', () => toggleMobileMenu());
}
// Add UTM to Download buttons (optional for analytics)
const dlButtons = Array.from(document.querySelectorAll('a[href*="YOUR_DOWNLOAD_LINK"], #download-hero'));
dlButtons.forEach(btn => {
btn.addEventListener('click', () => {
// Replace with your analytics if needed
console.log('Download clicked');
});
});
// Reduce motion preference: disable smooth scrolling if requested by user
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
document.documentElement.style.scrollBehavior = 'auto';
}