-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
96 lines (82 loc) · 3.19 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
// Change Heights When Page Is Loaded
const loadHandle = () => {
const headerHeight = document.querySelector(".header").offsetHeight;
document.querySelector("#homeHeader").style.top = `${-headerHeight}px`;
document.querySelector("#worksHeader").style.top = `${document.querySelector(".works").offsetTop - headerHeight}px`;
document.querySelector("#aboutHeader").style.top = `${document.querySelector(".about").offsetTop - headerHeight}px`;
document.querySelector("#contactHeader").style.top = `${document.querySelector(".contact").offsetTop - headerHeight}px`;
document.querySelector("#javascriptSection").style.top = `${document.querySelector("#javascriptSection").offsetTop - headerHeight}px`;
document.querySelector("#pythonSection").style.top = `${document.querySelector("#pythonSection").offsetTop - headerHeight}px`;
document.querySelector("#graphicdesignSection").style.top = `${document.querySelector("#graphicdesignSection").offsetTop - headerHeight}px`;
document.querySelector("#videoeditingSection").style.top = `${document.querySelector("#videoeditingSection").offsetTop - headerHeight}px`;
scrollHandle();
};
// Change Colors Of Header Depending On Section
const navItems = [document.querySelector(".navHome a"), document.querySelector(".navWorks a"), document.querySelector(".navAbout a"), document.querySelector(".navContact a")];
const assignColor = param => {
for (let i = 0; i < navItems.length; ++i) {
navItems[i].style.color = i == param ? "var(--primary-color)" : "var(--text-color)";
}
};
const header = document.querySelector(".header");
const home = document.querySelector(".home");
const works = document.querySelector(".works");
const about = document.querySelector(".about");
const contact = document.querySelector(".contact");
const scrollHandle = () => {
const headerHeight = header.offsetHeight;
const homePos = home.getBoundingClientRect().top;
const worksPos = works.getBoundingClientRect().top;
const aboutPos = about.getBoundingClientRect().top;
const contactPos = contact.getBoundingClientRect().top;
if (contactPos <= headerHeight + window.innerHeight / 2) {
assignColor(3);
} else if (aboutPos <= headerHeight + window.innerHeight / 2) {
assignColor(2);
} else if (worksPos <= headerHeight + window.innerHeight / 2) {
assignColor(1);
} else if (homePos <= headerHeight + window.innerHeight / 2) {
assignColor(0);
}
};
window.addEventListener("scroll", scrollHandle);
// Day Js
const timeStart = new Date("04/25/2002");
const years = () => {
const time = dayjs().diff(dayjs(timeStart.getTime()), "year", true);
return time.toString().substring(0, 11);
};
const currentAge = document.querySelector("#years");
setInterval(() => {
currentAge.innerText = years();
}, 50);
// Scroll Reveal
window.sr = ScrollReveal({reset: false});
sr.reveal(".header", {
duration: 500,
origin: "top",
distance: "3rem"
});
sr.reveal(".sectionTitle", {
duration: 500,
origin: "top",
distance: "3rem"
});
sr.reveal(".workElement", {
duration: 1000,
origin: "bottom",
distance: "5rem"
});
sr.reveal(".aboutSkill", {
duration: 500,
scale: 0.8
});
sr.reveal(".aboutFolder", {
duration: 1000,
scale: 0.8
});
sr.reveal(".contactLink", {
duration: 1000,
origin: "left",
distance: "5rem"
});