-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
87 lines (72 loc) · 2.02 KB
/
index.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
const pageTurnBtn = document.querySelectorAll(".nextprev-btn");
pageTurnBtn.forEach((el, index) => {
el.onclick = () => {
const pageTurnId = el.getAttribute("data-page");
const pageTurn = document.getElementById(pageTurnId);
if (pageTurn.classList.contains("turn")) {
pageTurn.classList.remove("turn");
setTimeout(() => {
pageTurn.style.zIndex = 20 - index;
}, 500);
} else {
pageTurn.classList.add("turn");
setTimeout(() => {
pageTurn.style.zIndex = 20 + index;
}, 500);
}
};
});
const pages = document.querySelectorAll(".book-page.page-right");
const contactMeBtn = document.querySelector(".btn.contact-me");
contactMeBtn.onclick = () => {
pages.forEach((page, index) => {
setTimeout(() => {
page.classList.add("turn");
setTimeout(() => {
page.style.zIndex = 20 + index;
}, 500);
}, (index + 1) * 200 + 100);
});
};
let totalPages = pages.length;
let pageNumber = 0;
function reverseIndex() {
pageNumber--;
if (pageNumber < 0) {
pageNumber = totalPages - 1;
}
}
const backProfileBtn = document.querySelector(".back-profile");
backProfileBtn.onclick = () => {
pages.forEach((_, index) => {
setTimeout(() => {
reverseIndex();
pages[pageNumber].classList.remove("turn");
setTimeout(() => {
reverseIndex();
pages[pageNumber].style.zIndex = 10 + index;
}, 500);
}, (index + 1) * 200 + 100);
});
};
const coverRight = document.querySelector(".cover.cover-right");
const pageLeft = document.querySelector(".book-page.page-left");
setTimeout(() => {
coverRight.classList.add("turn");
}, 2100);
setTimeout(() => {
coverRight.style.zIndex = -1;
}, 2800);
setTimeout(() => {
pageLeft.style.zIndex = 20;
}, 3200);
pages.forEach((_, index) => {
setTimeout(() => {
reverseIndex();
pages[pageNumber].classList.remove("turn");
setTimeout(() => {
reverseIndex();
pages[pageNumber].style.zIndex = 10 + index;
}, 500);
}, (index + 1) * 200 + 2100);
});