-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
78 lines (74 loc) · 2.63 KB
/
script.js
File metadata and controls
78 lines (74 loc) · 2.63 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
77
78
// Hamburger menu toggle
const hamburger = document.getElementById('mm-hamburger');
const menu = document.getElementById('mm-menu');
if (hamburger && menu) {
hamburger.addEventListener('click', () => {
menu.classList.toggle('open');
});
// Close menu on link click (mobile)
menu.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
if (window.innerWidth <= 768) menu.classList.remove('open');
});
});
// Close menu on outside click
document.addEventListener('click', (e) => {
if (!menu.contains(e.target) && !hamburger.contains(e.target)) {
menu.classList.remove('open');
}
});
}
// Dropdowns: open on click (mobile), hover (desktop)
const dropdownParents = document.querySelectorAll('.mm-has-dropdown');
dropdownParents.forEach(parent => {
const dropdown = parent.querySelector('.mm-dropdown');
if (!dropdown) return;
// Desktop: open on hover (handled by CSS)
// Mobile: open on click
parent.addEventListener('click', (e) => {
if (window.innerWidth <= 768) {
e.preventDefault();
dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block';
}
});
// Close dropdown on outside click (mobile)
document.addEventListener('click', (e) => {
if (window.innerWidth <= 768 && !parent.contains(e.target)) {
dropdown.style.display = 'none';
}
});
});
// Dropdown: open on click only (desktop & mobile)
const solutionsDropdownParent = document.querySelector('.mm-has-dropdown');
const solutionsDropdown = solutionsDropdownParent?.querySelector('.mm-dropdown');
const solutionsLink = solutionsDropdownParent?.querySelector('.mm-menu-link');
if (solutionsDropdownParent && solutionsDropdown && solutionsLink) {
solutionsLink.addEventListener('click', (e) => {
e.preventDefault();
solutionsDropdownParent.classList.toggle('open');
});
// Close dropdown on outside click
document.addEventListener('click', (e) => {
if (!solutionsDropdownParent.contains(e.target)) {
solutionsDropdownParent.classList.remove('open');
}
});
}
// Animate sections on scroll
function animateOnScroll() {
const animatedSections = document.querySelectorAll('.mm-animate-fade, .mm-animate-slide');
const observer = new window.IntersectionObserver((entries, obs) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('mm-animated');
obs.unobserve(entry.target);
}
});
}, { threshold: 0.15 });
animatedSections.forEach(section => {
observer.observe(section);
});
}
if (window.IntersectionObserver) {
window.addEventListener('DOMContentLoaded', animateOnScroll);
}