-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
83 lines (68 loc) · 2.16 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
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');
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');
setTimeout(() => {
coverRight.classList.add('turn');
},2100);
setTimeout(() => {
coverRight.style.zIndex = -1;
},2800);
pages.forEach((_, index) => {
setTimeout(() => {
reverseIndex();
pages[pageNumber].classList.remove('turn');
setTimeout(() => {
reverseIndex();
pages[pageNumber].style.zIndex = 10 + index;
},500);
}, (index + 1) * 200 + 2100);
})