-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
61 lines (46 loc) · 1.6 KB
/
script.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
// script.js
document.addEventListener("DOMContentLoaded", () => {
const sections = document.querySelectorAll("section");
const options = {
root: null,
rootMargin: "0px",
threshold: 0.1,
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("slide-in");
observer.unobserve(entry.target); // Optional: Stop observing once animation is applied
}
});
}, options);
sections.forEach((section) => {
observer.observe(section);
});
});
// Add an event listener to the hamburger menu button
// script.js
document.addEventListener('DOMContentLoaded', () => {
const hamburger = document.getElementById('hamburger');
const overlay = document.getElementById('overlay');
const closeBtn = document.getElementById('close-btn');
const searchInput = document.getElementById('search__input');
const body = document.body;
hamburger.addEventListener('click', () => {
overlay.classList.add('active');
searchInput.style.display="none"
overlay.style.scrollBehavior="none"
body.classList.add('no-scroll');
});
closeBtn.addEventListener('click', () => {
overlay.classList.remove('active');
body.classList.remove('no-scroll');
});
// Close the overlay when clicking outside of the menu links
overlay.addEventListener('click', (e) => {
if (e.target === overlay) {
overlay.classList.remove('active');
body.classList.remove('no-scroll');
}
});
});