-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
95 lines (82 loc) · 2.92 KB
/
app.js
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
document.addEventListener('DOMContentLoaded', function () {
const serviceItems = document.querySelectorAll('.service-item');
const faqItems = document.querySelectorAll('.faq-item');
const workItems = document.querySelectorAll('.process-step');
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.1
});
serviceItems.forEach(item => {
observer.observe(item);
});
faqItems.forEach(item => {
observer.observe(item);
});
workItems.forEach(item => {
observer.observe(item);
});
const modals = document.querySelectorAll('.modal');
const openButtons = document.querySelectorAll('.open-modal');
const closeButtons = document.querySelectorAll('.modal .close');
openButtons.forEach(button => {
button.addEventListener('click', (event) => {
const service = event.currentTarget.getAttribute('data-service');
const modal = document.querySelector(`#modal-${service}`);
if (modal) {
modal.style.display = 'block';
setTimeout(() => {
modal.setAttribute('open', '');
}, 10);
}
});
});
closeButtons.forEach(button => {
button.addEventListener('click', (event) => {
const modal = event.currentTarget.closest('.modal');
if (modal) {
modal.removeAttribute('open');
setTimeout(() => {
modal.style.display = 'none';
}, 200);
}
});
});
window.addEventListener('click', (event) => {
modals.forEach(modal => {
if (event.target === modal) {
modal.removeAttribute('open');
setTimeout(() => {
modal.style.display = 'none';
}, 200);
}
});
});
// Menu functionality
const menuButton = document.getElementById('menu');
const closeButton = document.getElementById('close-menu');
const menuModal = document.getElementById('menu-modal');
const menuItems = document.querySelectorAll('.menu-item');
const logo = document.querySelector('.menu-logo');
if (menuButton && closeButton && menuModal) {
menuButton.addEventListener('click', function () {
menuModal.showModal();
});
closeButton.addEventListener('click', function () {
menuModal.close();
});
menuItems.forEach(item => {
item.addEventListener('click', function () {
menuModal.close();
});
});
logo.addEventListener('click', function () {
menuModal.close();
});
}
});