-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
56 lines (43 loc) · 1.33 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
"use strict";
// MENU TOGGLER
const hamburger = document.querySelector(".hamburger");
const close = document.querySelector(".close");
const navUl = document.querySelector(".nav-ul");
const header = document.querySelector("header");
hamburger.addEventListener("click", function () {
navUl.classList.toggle("show");
hamburger.classList.toggle("hide");
});
close.addEventListener("click", function () {
navUl.classList.toggle("show");
hamburger.classList.toggle("hide");
});
// Modal Section
const btn = document.querySelector(".searching");
const modal = document.querySelector(".modal");
const closeModal = document.querySelector(".close-modal");
btn.addEventListener("click", openPopup);
closeModal.addEventListener("click", closePopup);
function openPopup() {
modal.style.display = "block";
}
function closePopup() {
modal.style.display = "none";
}
AOS.init({
duration: 1000,
});
const nav = document.querySelector(".nav");
const navHeight = nav.getBoundingClientRect().height - 100;
const stickyNav = function (entries) {
const [entry] = entries;
// console.log(entry);
if (!entry.isIntersecting) nav.classList.add("sticky");
else nav.classList.remove("sticky");
};
const headerObserver = new IntersectionObserver(stickyNav, {
root: null,
threshold: 0,
rootMargin: `-${navHeight}px`,
});
headerObserver.observe(header);