-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
128 lines (103 loc) · 3.37 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
124
125
126
127
const navSlide = () => {
const burger = document.querySelector(".burger");
const nav = document.querySelector(".nav-links");
const navLinks = document.querySelectorAll(".nav-links li");
burger.addEventListener("click", () => {
//Toggle Nav
nav.classList.toggle("nav-active");
//Animate Links
navLinks.forEach((link,index) => {
if (link.style.animation){
link.style.animation = "";
}
else{
link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.3}s`;
console.log(index/7 + 0.3);
}
});
//Burger Animation
burger.classList.toggle("toggle");
});
}
navSlide();
//Below is for spin loading animation
window.addEventListener("load", () => {
const loader = document.querySelector(".loader");
//loader without delay
//loader.classList.add("loader-hidden");
setTimeout(() => loader.classList.add("loader-hidden"), 1000);
/*
loader.addEventListener("transitionend", () => {
document.body.removeChild("loader");
});
*/
});
//Below is for cursor
let mouseCursor = document.querySelector(".cursor");
let navLinks = document.querySelectorAll(".nav-links li");
let projectLinks = document.querySelectorAll(".project-boxes a");
let logo = document.querySelector(".logo");
let footLinks = document.querySelector(".foot a");
let spotlightHeads = document.querySelector(".spotlight h1");
let spotlightLinks = document.querySelector(".spotlight a");
let aboutContentsH2 = document.querySelector(".about-contents h2");
let socials = document.querySelectorAll(".social-icon");
window.addEventListener("mousemove", cursor);
function cursor(e){
mouseCursor.style.top = e.clientY + "px";
mouseCursor.style.left = e.clientX + "px";
}
navLinks.forEach(link => {
link.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
link.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
});
projectLinks.forEach(link => {
link.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
link.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
});
socials.forEach(socialIcon => {
socialIcon.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
socialIcon.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
});
logo.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
logo.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
footLinks.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
footLinks.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
spotlightHeads.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
spotlightHeads.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
spotlightLinks.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
spotlightLinks.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});
aboutContentsH2.addEventListener("mouseover", () => {
mouseCursor.classList.add("link-grow");
});
aboutContentsH2.addEventListener("mouseleave", () => {
mouseCursor.classList.remove("link-grow");
});