-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
399 lines (349 loc) · 10.5 KB
/
main.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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
let parent = document.querySelector(".featured-body");
let child = document.querySelector(".scroll-icon");
let menu_pull = document.querySelector(".menu-pull");
let menu_container = document.querySelector(".menu-container");
let menu_upper_right = document.querySelector(".menu-upper-right");
let menu_projects = document.querySelector(".menu-projects");
let featured_text = document.querySelector(".featured-text");
let menu_reach_me = document.querySelector(".menu-reach-me");
let third_page_content = document.querySelector(".third-page-content");
let menu_resources = document.querySelector(".menu-resources");
let fourth_page_content = document.querySelector(".fourth-page-content");
let show_reel = document.querySelector(".show-reel");
let menu_symbol = document.querySelector("#menu-symbol");
let view_projects_btn = document.querySelector(".view-projects");
let linkedin_btn = document.querySelector("#linkedin-btn");
let instagram_btn = document.querySelector("#instagram-btn");
let gmail_btn = document.querySelector("#gmail-btn");
let github_btn = document.querySelector("#github-btn");
let cursor_content = document.querySelector(".mf-cursor");
let bts_anshp = document.querySelector(".bts-anshp");
let anshp_cast = document.querySelector(".anshp-cast");
let sphere = document.querySelector(".sphere");
let spotify = document.querySelector(".spotify");
let gmail_a = document.querySelector(".gmail-a");
let nav = document.querySelector(".nav");
let home_page = document.querySelector("#home-page");
let content_container = document.querySelector(".content-container");
let end_home_page = document.querySelector(".end-home-page");
// cursor_content.style.color = "blue";
if (screen.width >= 600) {
const cursor = new MouseFollower({
el: null,
container: '#main',
className: 'mf-cursor',
innerClassName: 'mf-cursor-inner',
textClassName: 'mf-cursor-text',
mediaClassName: 'mf-cursor-media',
mediaBoxClassName: 'mf-cursor-media-box',
iconSvgClassName: 'mf-svgsprite',
iconSvgNamePrefix: '-',
iconSvgSrc: '',
dataAttr: 'cursor',
hiddenState: '-hidden',
textState: '-text',
iconState: '-icon',
activeState: '-active',
mediaState: '-media',
stateDetection: {
'-pointer': 'a,button',
'-hidden': 'iframe'
},
visible: true,
visibleOnState: false,
speed: 0.55,
ease: 'expo.out',
overwrite: true,
skewing: 0,
skewingText: 2,
skewingIcon: 1,
skewingMedia: 2,
skewingDelta: 0.001,
skewingDeltaMax: 0.15,
stickDelta: 0.15,
showTimeout: 20,
hideOnLeave: true,
hideTimeout: 300,
hideMediaTimeout: 300,
});
}
// if (screen.width < 600) {
// cursor.hide();
// }
// cursor.style.backgroundColor = "red";
gsap.registerPlugin(ScrollTrigger);
// gsap.registerPlugin(ScrollSmoother);
// gsap.registerPlugin(ScrollTrigger, ScrollSmoother);
// let smoother = ScrollSmoother.create({
// wrapper: '#main',
// content: '#home-page',
// smooth: 1,
// effects: true,
// normalizeScroll: true
// });
gsap.to(".scroll-icon", {
scrollTrigger: {
trigger: ".scroll-1",
start: "top center",
end: "top 100px",
markers: false,
scrub: 1,
},
x: "72vw",
duration: 1,
ease: "none"
});
// gsap.registerPlugin(ScrollTrigger, ScrollSmoother);
// ScrollTrigger.normalizeScroll(true)
// create the smooth scroller FIRST!
// let smoother = ScrollSmoother.create({
// smooth: 2,
// effects: true,
// normalizeScroll: true
// });
let mouse_cusor = document.querySelector('.mouseCursor');
let main_page = document.querySelector('#main');
let details_global;
window.addEventListener("mousemove", function (details) {
details_global = details;
gsap.to(mouse_cusor, {
x: details.clientX,
y: details.pageY
})
})
// function update() {
// window.requestAnimationFrame(update);
// // gsap.to(mouse_cusor, {
// // // x: details_global.clientX,
// // y: (-1 * main_page.getBoundingClientRect().top) + 400,
// // })
// console.log(main_page.getBoundingClientRect().top);
// console.log(main_page.getBoundingClientRect().bottom);
// }
// update();
let menu_opcl = 0;
function menuOpen() {
if (screen.width > 600) {
gsap.to(menu_container, {
x: "-21vw",
duration: 1,
ease: Power2
});
}
else {
gsap.to(menu_container, {
x: "-49.5vw",
duration: 1,
ease: Power2
});
}
console.log(menu_opcl);
setTimeout(() => {
menu_opcl = 1;
console.log(menu_opcl);
console.log("value going to be opened")
}, 1100);
// menu_opcl = 1
// console.log(menu_opcl);
}
function menuClose() {
if (screen.width > 600) {
gsap.to(menu_container, {
x: "20vw",
duration: 1,
ease: Power2
});
}
else {
gsap.to(menu_container, {
x: "51vw",
duration: 1,
ease: Power2
});
}
menu_opcl = 0;
console.log(menu_opcl);
setTimeout(() => {
menu_opcl = 0;
console.log(menu_opcl);
console.log("value going to be closed")
}, 1100);
}
menu_pull.addEventListener("click", () => {
console.log("clicked menu - pull");
menuOpen();
console.log(screen.width)
});
menu_upper_right.addEventListener("click", () => {
console.log("clicked menu close logo");
menuClose();
});
menu_symbol.addEventListener("click", () => {
console.log("clicked menu - symbol");
menuOpen();
console.log(screen.width)
});
// window.addEventListener("scroll" ,() => {
// console.log("scroll on window")
// gsap.to(menu_container,{
// x:"20vw",
// duration: 2,
// ease: Power2
// });
// })
menu_projects.addEventListener("click", () => {
gsap.to(window, {
scrollTo: featured_text.getBoundingClientRect().top,
duration: 2
})
menuClose();
})
menu_reach_me.addEventListener("click", () => {
gsap.to(window, {
scrollTo: third_page_content.getBoundingClientRect().top,
duration: 2
})
menuClose();
})
show_reel.addEventListener("click", () => {
gsap.to(window, {
scrollTo: featured_text.getBoundingClientRect().top,
duration: 2
})
menuClose();
})
menu_resources.addEventListener("click", () => {
gsap.to(window, {
scrollTo: fourth_page_content.getBoundingClientRect().top,
duration: 2
})
menuClose();
})
function skipBtn() {
view_projects_btn.addEventListener("click", () => {
window.open("https://github.com/ANSHPG", "_blank");
})
linkedin_btn.addEventListener("click", () => {
window.open("https://www.linkedin.com/in/anshuman-pattnaik-9694a3255", "_blank");
})
instagram_btn.addEventListener("click", () => {
window.open("https://www.instagram.com/anshphere", "_blank");
})
gmail_btn.addEventListener("click", () => {
// let subject = "Want to connect";
// let body = "Hello nice to meet you,"
window.open("mailto:helloanshu04@gmail.com?subject=" + subject + "&body=" + body, "_blank");
})
github_btn.addEventListener("click", () => {
window.open("https://github.com/ANSHPG", "_blank");
})
bts_anshp.addEventListener("click", () => {
window.open("https://github.com/ANSHPG/Chordopolis-ANSHP", "_blank");
})
anshp_cast.addEventListener("click", () => {
window.open("https://github.com/ANSHPG/WeatherApp-ANSHP", "_blank");
})
sphere.addEventListener("click", () => {
window.open("https://github.com/ANSHPG/SPHERE-ANSHP", "_blank");
})
spotify.addEventListener("click", () => {
window.open("https://github.com/ANSHPG/SPOTIFY-ANSHP", "_blank");
})
}
function animation_first() {
let timeLine = gsap.timeline();
timeLine.from(nav, {
y: '-10',
opacity: 0,
duration: 1,
ease: Expo.easeInOut
})
.to(".cover-content", {
y: '0',
ease: Expo.easeInOut,
duration: 1,
stagger: 0.3
})
.to(".end-content", {
x: '0',
ease: Expo.easeInOut,
duration: 1,
stagger: 0.3
})
}
animation_first();
// let positionX;
// let positionY;
// window.addEventListener("mousemove", (details) => {
// positionX = details.clientX;
// positionY = details.clientY;
// })
// home_page.addEventListener("click", () => {
// console.log("clicked")
// if (positionX < menu_container.getBoundingClientRect().left) {
// if (positionY > menu_container.getBoundingClientRect().top) {
// if (menu_opcl == 1) {
// menuClose();
// console.log("closed Menu");
// }
// }
// }
// })
// content_container.addEventListener("click", () => {
// if (menu_opcl == 1) {
// menuClose();
// console.log("closed Menu")
// }
// })
// function checkPosition() {
// let positionX;
// let positionY;
// window.addEventListener("mousemove", (details) => {
// positionX = details.clientX;
// positionY = details.clientY;
// })
// if (positionX < menu_container.getBoundingClientRect().left) {
// if (positionY > menu_container.getBoundingClientRect().bottom) {
// return 1;
// }
// else {
// return 0;
// }
// }
// else {
// return 0;
// }
// }
// window.addEventListener("click",() => {
// if(checkPosition() == 1) {
// if(menu_opcl == 1) {
// menuClose();
// console.log("close - 2")
// }
// }
// })
window.addEventListener('click', function (e) {
if (menu_container.contains(e.target)) {
// Clicked in box
console.log("clicked inside box");
} else {
// Clicked outside the box
console.log("clicked outside the box");
if (menu_opcl == 1) {
console.log("closing outside div")
menuClose()
}
}
});
window.addEventListener("scroll", () => {
console.log(menu_container.getBoundingClientRect())
console.log(end_home_page.getBoundingClientRect().top)
if (menu_opcl == 1) {
if (menu_container.getBoundingClientRect().bottom <= 0) {
menuClose();
}
}
})
window.onbeforeunload = function () {
window.scrollTo(0, 0);
}