-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
59 lines (52 loc) · 1.34 KB
/
script.js
File metadata and controls
59 lines (52 loc) · 1.34 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
const roles = [
"@Crossover - Software Developer Engineer I",
"@Insight Gro - Chief Technology Officer",
"@Fiverr - Freelance Software Developer",
"@Aviyel - Community Manager",
"@ProGrad - Full Stack Developer",
"@Micro-Star International - Junior Software Developer",
];
const roleElement = document.getElementById("role");
let roleIndex = 0;
let charIndex = 0;
function typeRole() {
if (charIndex < roles[roleIndex].length) {
roleElement.innerHTML += roles[roleIndex].charAt(charIndex);
charIndex++;
setTimeout(typeRole, 50);
} else {
setTimeout(eraseRole, 1500);
}
}
function eraseRole() {
if (charIndex > 0) {
roleElement.textContent = roles[roleIndex].substring(0, charIndex - 1);
charIndex--;
setTimeout(eraseRole, 50);
} else {
roleIndex = (roleIndex + 1) % roles.length;
setTimeout(typeRole, 1000);
}
}
typeRole();
$("#navbar a, .btn").on("click", function (event) {
if (this.hash !== "") {
event.preventDefault();
const hash = this.hash;
$("html, body").animate(
{
scrollTop: $(hash).offset().top - 100,
},
800
);
}
});
window.addEventListener("scroll", function () {
if (window.scrollY > 150) {
document.querySelector("#navbar").style.opacity = 0.9;
} else {
document.querySelector("#navbar").style.opacity = 1;
}
}
);
// Path: style.css