-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
191 lines (171 loc) · 5.6 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
function create(tag, parent, text = null, classs = null, id = null) {
let element = document.createElement(tag);
if (text) element.appendChild(document.createTextNode(text));
parent.appendChild(element);
if (classs) element.classList.add(classs);
if (id) element.id = id;
return element;
}
//*user mouse
let newCursor = create("div", document.body, null, "cursor", null);
const cursor = document.querySelector(".cursor");
document.addEventListener("mousemove", (e) => {
cursor.setAttribute("style", "top: " + (e.pageY - 17) + "px; left: " + (e.pageX - 17) + "px;");
});
document.addEventListener("mousedown", () => {
cursor.classList.add("click");
document.addEventListener("mouseup", () => {
cursor.classList.remove("click");
});
});
//*bottom navbar
let navLink = document.querySelectorAll("nav a");
navLink.forEach((element, index) => {
//*cursor style
element.addEventListener("mouseenter", () => {
cursor.classList.add("mouseHover");
});
element.addEventListener("mouseleave", () => {
cursor.classList.remove("mouseHover");
});
element.addEventListener("click", () => {
actualLinkPage = window.location.href;
if (index == 0) {
//*ask link is project page
askPage = "index.html";
if (actualLinkPage.includes(askPage)) {
console.log("same page");
} else {
createTransition();
setTimeout(() => {
window.location.href = "../index.html";
}, 850);
}
} else if (index == 1) {
//*ask link is project page
askPage = "aboutP.html";
if (actualLinkPage.includes(askPage)) {
console.log("same page");
} else {
createTransition();
setTimeout(() => {
window.location.href = "about/aboutP.html";
}, 850);
}
}
});
});
//*transition between page
let pageTransition = document.querySelector(".pageTransition");
function createTransition() {
pageTransition.classList.remove("desactive");
pageTransition.classList.add("animationSlideUp");
setTimeout(() => {
pageTransition.classList.add("endAnimation");
}, 400);
}
//*left link button
let containerButton = create("section", document.body, null, "containerButton")
let CVbutton = create("a", containerButton, null, "leftButton");
let CVIconButton = create("i",CVbutton, null )
CVIconButton.classList.add("fa-solid")
CVIconButton.classList.add("fa-file-lines")
CVIconButton.classList.add("fa-xl")
CVbutton.href='/assets/aboutAssets/curriculumVitae.pdf'
CVbutton.setAttribute("target", "_blank");
let githubButton = create("a", containerButton, null, "leftButton");
let githubIconButton = create("i",githubButton, null )
githubIconButton.classList.add("fa-brands")
githubIconButton.classList.add("fa-github")
githubIconButton.classList.add("fa-xl")
githubButton.href='https://github.com/lorrisc'
githubButton.setAttribute("target", "_blank");
//* MOUSE ANIMATION ON HOVER LINK
let buttonLink = document.querySelectorAll(".leftButton");
buttonLink.forEach((element, index) => {
element.addEventListener("mouseenter", () => {
cursor.classList.add("mouseHover");
});
element.addEventListener("mouseleave", () => {
cursor.classList.remove("mouseHover");
});
});
//*credit
let creditContainer = create("div", document.body, null, "credit", null);
let creditText = "Developed by Lorris Crappier";
let creditTextArray = creditText.split("");
creditTextArray.forEach((element) => {
if (element == " ") {
let letter = create("p", creditContainer, " ", null, null);
letter.style.marginRight = "5px";
} else {
let letter = create("p", creditContainer, element, null, null);
}
});
//*credit on hover
let colorElement = [
"#BBFF00",
"#BBFF00",
"#D4FF00",
"#D4FF00",
"#EEFF00",
"#EEFF00",
"#FFF600",
"#FFF600",
"#FFDC00",
"#FFDC00",
"#FFDC00",
"#FFC300",
"#FFC300",
"#FFC300",
"#FFAA00",
"#FFAA00",
"#FF9400",
"#FF9400",
"#FF7B00",
"#FF7B00",
"#FF7B00",
"#FF6100",
"#FF6100",
"#FF4800",
"#FF4800",
"#FF2E00",
"#FF2E00",
"#FF1500",
];
let creditLetter = document.querySelectorAll(".credit p");
creditContainer.addEventListener("mouseenter", (e) => {
let i = 0;
function uncolorElementFunc(indexelement) {
setTimeout(() => {
creditLetter[indexelement].style.color = "#939393";
}, 600);
}
function colorElementFunct() {
creditLetter[i].style.color = colorElement[i];
uncolorElementFunc(i);
i++;
if (i < creditLetter.length) {
setTimeout(colorElementFunct, 35);
}
}
colorElementFunct();
});
//*scroll indicator
let scrollDown = document.querySelector("#scrollDown"); //bottom text indicator
let scrollValue = [0];
addEventListener("scroll", function () {
var y = window.scrollY;
scrollValue[1] = y;
cursor.setAttribute("style", "top: " + (scrollValue[0] - scrollValue[1] - 17) + "px;");
scrollValue[0] = y;
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
let scrollIndicator = document.querySelector("#scrollIndicator");
scrollIndicator.style.height = scrolled + "%";
//bottom text indicator
if (scrollDown) {
scrollDown.classList.add("notActive");
}
});