-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
40 lines (33 loc) · 1.16 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
const model = document.querySelector(".pop-up");
const overlay = document.querySelector(".overlay");
const btnOpenModel = document.querySelectorAll(".request-btn");
const btnCloseModel = document.querySelector(".close-btn");
const Section1 = document.querySelector(".section-1");
const hamburger = document.querySelector(".hamburger");
const home = document.querySelector(".home");
const MobileView = document.querySelector(".mobile-view");
function openModal() {
model.classList.remove("hidden");
overlay.classList.remove("hidden");
}
function closeModal() {
model.classList.add("hidden");
overlay.classList.add("hidden");
}
//Loop over the all btn
btnOpenModel.forEach((btn) => btn.addEventListener("click", openModal));
btnCloseModel.addEventListener("click", function () {
closeModal();
});
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && !model.classList.contains("hidden")) {
closeModal();
}
});
home.addEventListener("click", function () {
Section1.scrollIntoView({ behavior: "smooth" });
});
function openNavMobile() {
MobileView.classList.toggle("hidden-hamburger");
}
hamburger.addEventListener("click", openNavMobile);