-
Notifications
You must be signed in to change notification settings - Fork 0
/
imp.js
129 lines (110 loc) · 3.36 KB
/
imp.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const prevBtn = document.querySelector("#prev-btn");
const nextBtn = document.querySelector("#next-btn");
const book = document.querySelector("#book");
const paper1 = document.querySelector("#p1");
const paper2 = document.querySelector("#p2");
const paper3 = document.querySelector("#p3");
prevBtn.addEventListener("click", goPrevPage);
nextBtn.addEventListener("click", goNextPage);
let currentLocation = 1;
const numOfPapers = 3;
const maxLocation = numOfPapers + 1;
function openBook() {
book.style.transform = "translateX(50%)";
prevBtn.style.transform = "translateX(-180px)";
nextBtn.style.transform = "translateX(180px)";
}
function closeBook(isAtBeginning) {
if (isAtBeginning) {
book.style.transform = "translateX(0%)";
} else {
book.style.transform = "translateX(100%)";
}
prevBtn.style.transform = "translateX(0px)";
nextBtn.style.transform = "translateX(0px)";
}
function goNextPage() {
if (currentLocation < maxLocation) {
switch (currentLocation) {
case 1:
openBook();
paper1.classList.add("flipped");
paper1.style.zIndex = 1;
break;
case 2:
paper2.classList.add("flipped");
paper2.style.zIndex = 2;
break;
case 3:
paper3.classList.add("flipped");
paper3.style.zIndex = 3;
closeBook(false);
break;
default:
throw new Error("Unknown state");
}
currentLocation++;
updatePrevButtonVisibility();
updateNextButtonVisibility()
}
}
function goPrevPage() {
if (currentLocation > 1) {
switch (currentLocation) {
case 2:
closeBook(true);
paper1.classList.remove("flipped");
paper1.style.zIndex = 3;
break;
case 3:
paper2.classList.remove("flipped");
paper2.style.zIndex = 2;
break;
case 4:
openBook();
paper3.classList.remove("flipped");
paper3.style.zIndex = 1;
break;
default:
throw new Error("Unknown state");
}
currentLocation--;
updatePrevButtonVisibility();
updateNextButtonVisibility()
}
}
function updatePrevButtonVisibility() {
if (currentLocation === 1) {
prevBtn.style.display = "none";
} else {
prevBtn.style.display = "inline-block";
}
}
function updateNextButtonVisibility() {
if (currentLocation === 4) {
nextBtn.style.display = "none";
} else {
nextBtn.style.display = "inline-block";
}
}
updatePrevButtonVisibility();
const contactForm = document.querySelector("#contact-form");
contactForm.addEventListener("submit", function(event) {
event.preventDefault();
Toastify({
text: "Message has been sent",
duration: 3000,
gravity: "top",
position: "right",
backgroundColor: "green",
stopOnFocus: true,
style: {
color: "white",
boxShadow: "0 2px 10px rgba(0,0,0,0.2)",
borderRadius: "8px",
padding: "16px",
position: "absolute"
}
}).showToast();
contactForm.reset();
});