-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
123 lines (104 loc) · 3.33 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
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
let counter1 = 0;
let counter2 = 1;
let bool = true;
const sections = document.querySelectorAll("section");
const progress = document.querySelector(".progress h2");
const circles = document.querySelectorAll(".circle");
const menu = document.querySelector(".menu");
const section1wrapper = document.querySelector(".section-1-wrapper");
const section5wrapper = document.querySelector(".section-5-wrapper");
section1wrapper.style.transform = "scale(1)";
const progressCounter = () => {
progress.textContent = `${counter2}/${sections.length}`;
Array.from(circles).forEach((circle) => {
circle.style.backgroundColor = "transparent";
});
document.querySelector(`.circle-${counter2}`).style.backgroundColor = "#ddd";
};
const pageController = () => {
bool = true;
if (counter1 === 5) {
Array.from(sections).forEach((section) => {
section.style.left = "0";
});
counter1 = 0;
counter2 = 1;
section1wrapper.style.transform = "scale(1)";
section5wrapper.style.transform = "scale(1.5)";
progressCounter();
bool = false;
}
if (counter1 === -1) {
Array.from(sections).forEach((section) => {
if (section.classList[0] === "section-5") {
return;
}
section.style.left = "-100vw";
});
counter1 = 4;
counter2 = 5;
section1wrapper.style.transform = "scale(1.5)";
section5wrapper.style.transform = "scale(1)";
progressCounter();
bool = false;
}
progressCounter();
return bool;
};
window.addEventListener("wheel", (e) => {
const deltaY = e.deltaY > 0;
if (deltaY) {
counter1++;
counter2++;
} else {
counter1--;
counter2--;
}
pageController();
progressCounter();
console.log(counter1, counter2);
if (bool) {
document.querySelector(
`.section-${deltaY ? counter1 : counter2}`
).style.left = `${deltaY ? "-100vw" : "0"}`;
document.querySelector(
`.section-${deltaY ? counter1 : counter2}-wrapper`
).style.transform = `scale(${deltaY ? "1.5" : "1"})`;
document.querySelector(
`.section-${deltaY ? counter1 + 1 : counter2 + 1}-wrapper`
).style.transform = `scale(${deltaY ? "1" : "1.5"})`;
}
});
document.querySelector(".left-btn").addEventListener("click", () => {
counter1--;
counter2--;
pageController() &&
(document.querySelector(`.section-${counter2}`).style.left = "0");
if (bool) {
document.querySelector(`.section-${counter2}-wrapper`).style.transform =
"scale(1)";
document.querySelector(`.section-${counter2 + 1}-wrapper`).style.transform =
"scale(1.5)";
}
});
document.querySelector(".right-btn").addEventListener("click", () => {
counter1++;
counter2++;
pageController() &&
(document.querySelector(`.section-${counter1}`).style.left = "-100vw");
if (bool) {
document.querySelector(`.section-${counter2}-wrapper`).style.transform =
"scale(1)";
document.querySelector(`.section-${counter1}-wrapper`).style.transform =
"scale(1.5)";
}
});
document.querySelector(".grapes-img").addEventListener("mouseover", () => {
document.querySelector(".section-3-wrapper").style.opacity = ".5";
});
document.querySelector(".grapes-img").addEventListener("mouseout", () => {
document.querySelector(".section-3-wrapper").style.opacity = "1";
});
menu.addEventListener("click", () => {
document.querySelector(".navbar").classList.toggle("change");
});