-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathapp.js
34 lines (28 loc) · 892 Bytes
/
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
const container = document.querySelector(".page-container");
const pages = document.querySelectorAll(".page");
const toggleBtn = document.querySelector(".toggle-btn");
const ul = document.querySelector(".nav-list");
const overlay = document.querySelector(".overlay");
const links = document.querySelectorAll(".link");
let pageIndex = 0;
toggleBtn.addEventListener("click", () => {
toggleBtn.classList.toggle("active");
container.classList.toggle("active");
ul.classList.toggle("show");
});
links.forEach((item, i) => {
item.addEventListener("click", () => {
nextPage(i);
});
});
function nextPage(index) {
overlay.style.animation = `slide 1s linear 1`;
setTimeout(() => {
pages[pageIndex].classList.remove("active");
pages[index].classList.add("active");
pageIndex = index;
}, 500);
setTimeout(() => {
overlay.style.animation = null;
}, 1000);
}