-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
331 lines (295 loc) · 11.6 KB
/
app.js
File metadata and controls
331 lines (295 loc) · 11.6 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
//variables//
var floatingMenuisOpened = false;
var hiddenNavIsOpened = false;
var isDesktop = false;
var topMenuIsClicked = false;
var vw = document.documentElement.clientWidth;
const me = document.getElementById("me");
const png = document.getElementById("png");
const logo = document.querySelector(".logo");
const nav = document.querySelector(".nav");
const menu = document.getElementById("menu");
const mask = document.querySelector("#mask");
const button = document.getElementById("button-container");
const topMenu = document.getElementById("topMenu");
const hiddenNav = document.getElementById("hidden-nav");
const backToTop = document.getElementById("back-to-top");
const buttonClientProjects = document.getElementById("button-client-projects");
const buttonRatings = document.getElementById("button-ratings");
const buttonHireMe = document.getElementById("button-hire-me");
const buttonSocial = document.getElementById("button-social");
const menuLabel1 = document.getElementById("menuLabel1");
const menuLabel2 = document.getElementById("menuLabel2");
const menuLabel3 = document.getElementById("menuLabel3");
const menuLabel4 = document.getElementById("menuLabel4");
const above = document.getElementById("top");
const middle = document.getElementById("middle");
const bottom = document.getElementById("bottom");
const aboveTop = document.getElementById("top-top");
const middleTop = document.getElementById("middle-top");
const bottomTop = document.getElementById("bottom-top");
const project1 = document.querySelector("#project1");
const project2 = document.querySelector("#project2");
const project3 = document.querySelector("#project3");
const project4 = document.querySelector("#project4");
const black1 = document.querySelector("#black1");
const black2 = document.querySelector("#black2");
const black3 = document.querySelector("#black3");
const black4 = document.querySelector("#black4");
function setup() {
logo.classList.add("slideright");
nav.classList.add("slideright");
menu.classList.add("slideleft");
logo.classList.remove("slideleft");
nav.classList.remove("slideleft");
menu.classList.remove("slideright");
// Reset My Picture, Scroll symbol(png), set header to left
me.classList.remove("fade-out");
me.classList.add("fade-in");
png.classList.remove("fade-out");
png.classList.add("fade-in");
png.classList.add("scroll-down");
logo.classList.remove("slideright");
nav.classList.remove("slideright");
menu.classList.remove("slideleft");
logo.classList.add("slideleft");
nav.classList.add("slideleft");
menu.classList.add("slideright");
//Hide Floating Menu Items
backToTop.classList.remove("show-backToTop");
backToTop.classList.add("hide-backToTop");
buttonClientProjects.classList.remove("show-buttonClientProjects");
buttonClientProjects.classList.add("hide-buttonClientProjects");
buttonRatings.classList.remove("show-buttonRatings");
buttonRatings.classList.add("hide-buttonRatings");
buttonHireMe.classList.remove("show-buttonHireMe");
buttonHireMe.classList.add("hide-buttonHireMe");
buttonSocial.classList.remove("show-buttonSocial");
buttonSocial.classList.add("hide-buttonSocial");
// Hide hidden Nav
hiddenNav.classList.add("hide-hidden-nav");
hiddenNav.classList.remove("show-hidden-nav");
// Top Menu Default - closed
middleTop.classList.remove("slideright");
middleTop.classList.add("slideleft");
aboveTop.classList.remove("skew-down_above");
aboveTop.classList.add("skew-up_above");
bottomTop.classList.remove("skew-up_bottom");
bottomTop.classList.add("skew-down_bottom");
}
// Functions
function scrollEvents() {
const scrolled = window.scrollY;
if (scrolled == 0) {
logo.classList.remove("slideright");
nav.classList.remove("slideright");
menu.classList.remove("slideleft");
logo.classList.add("slideleft");
nav.classList.add("slideleft");
menu.classList.add("slideright");
}
if (scrolled) {
logo.classList.add("slideright");
nav.classList.add("slideright");
menu.classList.add("slideleft");
logo.classList.remove("slideleft");
nav.classList.remove("slideleft");
menu.classList.remove("slideright");
hiddenNavIsOpened = false;
}
if (scrolled >= 150) {
me.classList.add("fade-out");
me.classList.remove("fade-in");
png.classList.remove("scroll-down");
png.classList.remove("fade-in");
png.classList.add("fade-out");
} else {
me.classList.remove("fade-out");
me.classList.add("fade-in");
png.classList.remove("fade-out");
png.classList.add("fade-in");
png.classList.add("scroll-down");
hiddenNav.classList.remove("show-hidden-nav");
hiddenNav.classList.add("hide-hidden-nav");
if (floatingMenuisOpened) {
middle.classList.add("slideleft");
middle.classList.remove("slideright");
above.classList.remove("skew-down_above");
above.classList.add("skew-up_above");
bottom.classList.remove("skew-up_bottom");
bottom.classList.add("skew-down_bottom");
mask.classList.remove("mask-appear");
mask.classList.add("mask-disappear");
backToTop.classList.remove("show-backToTop");
backToTop.classList.add("hide-backToTop");
buttonClientProjects.classList.remove("show-buttonClientProjects");
buttonClientProjects.classList.add("hide-buttonClientProjects");
buttonRatings.classList.remove("show-buttonRatings");
buttonRatings.classList.add("hide-buttonRatings");
buttonHireMe.classList.remove("show-buttonHireMe");
buttonHireMe.classList.add("hide-buttonHireMe");
buttonSocial.classList.remove("show-buttonSocial");
buttonSocial.classList.add("hide-buttonSocial");
menuLabel1.classList.remove("show-iconHolderName");
menuLabel1.classList.add("hide-iconHolderName");
menuLabel2.classList.remove("show-iconHolderName");
menuLabel2.classList.add("hide-iconHolderName");
menuLabel3.classList.remove("show-iconHolderName");
menuLabel3.classList.add("hide-iconHolderName");
menuLabel4.classList.remove("show-iconHolderName");
menuLabel4.classList.add("hide-iconHolderName");
floatingMenuisOpened = false;
}
}
if (scrolled >= 300) {
black1.classList.remove("lighten");
black1.classList.add("darken");
} else {
black1.classList.remove("darken");
black1.classList.add("lighten");
}
if (scrolled >= 1100) {
black1.classList.remove("darken");
black1.classList.add("lighten");
black2.classList.add("darken");
black2.classList.remove("lighten");
} else {
black2.classList.remove("darken");
black2.classList.add("lighten");
}
if (scrolled >= 1650) {
black2.classList.remove("darken");
black2.classList.add("lighten");
black3.classList.add("darken");
black3.classList.remove("lighten");
} else {
black3.classList.remove("darken");
black3.classList.add("lighten");
}
if (scrolled >= 2350) {
black3.classList.remove("darken");
black3.classList.add("lighten");
black4.classList.add("darken");
black4.classList.remove("lighten");
} else {
black4.classList.remove("darken");
black4.classList.add("lighten");
}
if (scrolled >= 3000) {
black4.classList.remove("darken");
black4.classList.add("lighten");
}
}
function TopMenu() {
if (!topMenuIsClicked) {
middleTop.classList.add("slideright");
middleTop.classList.remove("slideleft");
aboveTop.classList.add("skew-down_above");
aboveTop.classList.remove("skew-up_above");
bottomTop.classList.add("skew-up_bottom");
bottomTop.classList.remove("skew-down_bottom");
if (vw < 1000) {
hiddenNav.classList.remove("hide-hidden-nav");
hiddenNav.classList.add("show-hidden-nav");
}
} else {
middleTop.classList.remove("slideright");
middleTop.classList.add("slideleft");
aboveTop.classList.remove("skew-down_above");
aboveTop.classList.add("skew-up_above");
bottomTop.classList.remove("skew-up_bottom");
bottomTop.classList.add("skew-down_bottom");
if (vw < 1000) {
hiddenNav.classList.add("hide-hidden-nav");
hiddenNav.classList.remove("show-hidden-nav");
}
}
topMenuIsClicked = !topMenuIsClicked;
}
function FloatingMenu() {
if (!floatingMenuisOpened) {
middle.classList.add("slideright");
middle.classList.remove("slideleft");
above.classList.add("skew-down_above");
above.classList.remove("skew-up_above");
bottom.classList.add("skew-up_bottom");
bottom.classList.remove("skew-down_bottom");
mask.classList.add("mask-appear");
mask.classList.remove("mask-disappear");
backToTop.classList.add("show-backToTop");
backToTop.classList.remove("hide-backToTop");
buttonClientProjects.classList.add("show-buttonClientProjects");
buttonClientProjects.classList.remove("hide-buttonClientProjects");
buttonRatings.classList.add("show-buttonRatings");
buttonRatings.classList.remove("hide-buttonRatings");
buttonHireMe.classList.add("show-buttonHireMe");
buttonHireMe.classList.remove("hide-buttonHireMe");
buttonSocial.classList.add("show-buttonSocial");
buttonSocial.classList.remove("hide-buttonSocial");
menuLabel1.classList.add("show-iconHolderName");
menuLabel1.classList.remove("hide-iconHolderName");
menuLabel2.classList.add("show-iconHolderName");
menuLabel2.classList.remove("hide-iconHolderName");
menuLabel3.classList.add("show-iconHolderName");
menuLabel3.classList.remove("hide-iconHolderName");
menuLabel4.classList.add("show-iconHolderName");
menuLabel4.classList.remove("hide-iconHolderName");
} else {
middle.classList.add("slideleft");
middle.classList.remove("slideright");
above.classList.remove("skew-down_above");
above.classList.add("skew-up_above");
bottom.classList.remove("skew-up_bottom");
bottom.classList.add("skew-down_bottom");
mask.classList.remove("mask-appear");
mask.classList.add("mask-disappear");
backToTop.classList.remove("show-backToTop");
backToTop.classList.add("hide-backToTop");
buttonClientProjects.classList.remove("show-buttonClientProjects");
buttonClientProjects.classList.add("hide-buttonClientProjects");
buttonRatings.classList.remove("show-buttonRatings");
buttonRatings.classList.add("hide-buttonRatings");
buttonHireMe.classList.remove("show-buttonHireMe");
buttonHireMe.classList.add("hide-buttonHireMe");
buttonSocial.classList.remove("show-buttonSocial");
buttonSocial.classList.add("hide-buttonSocial");
menuLabel1.classList.remove("show-iconHolderName");
menuLabel1.classList.add("hide-iconHolderName");
menuLabel2.classList.remove("show-iconHolderName");
menuLabel2.classList.add("hide-iconHolderName");
menuLabel3.classList.remove("show-iconHolderName");
menuLabel3.classList.add("hide-iconHolderName");
menuLabel4.classList.remove("show-iconHolderName");
menuLabel4.classList.add("hide-iconHolderName");
}
floatingMenuisOpened = !floatingMenuisOpened;
}
function hiddenSelected() {
hiddenNav.classList.add("hide-hidden-nav");
hiddenNav.classList.remove("show-hidden-nav");
}
function startFunction() {
window.addEventListener("scroll", scrollEvents);
button.addEventListener("click", FloatingMenu);
hiddenNav.addEventListener("click", hiddenSelected);
}
function stopFunction() {
window.removeEventListener("scroll", scrollEvents);
button.removeEventListener("click", FloatingMenu);
hiddenNav.removeEventListener("click", hiddenSelected);
}
function main() {
setup();
if (vw < 1000) {
startFunction();
} else {
stopFunction();
}
}
//--------------------working part-----------//
topMenu.addEventListener("click", TopMenu);
main();
window.addEventListener("resize", function (event) {
vw = document.documentElement.clientWidth;
main();
});