-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (39 loc) · 1.36 KB
/
script.js
File metadata and controls
43 lines (39 loc) · 1.36 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
function toggleMenu(){
const menu = document.querySelector(".menu-links");
const icon = document.querySelector(".hamburger-icon");
menu.classList.toggle("open");
icon.classList.toggle("open");
}
const roles = ["Data Analyst", "Researcher", "Aspiring ML/AI Engineer", "Developer", "Designer"];
let currentRoleIndex = 0;
let charIndex = 0;
let isDeleting = false;
const typingSpeed = 80;
const erasingSpeed = 50;
const delayBetweenRoles = 1500;
function typeRole() {
const dynamicText = document.getElementById("dynamic-text");
if (isDeleting) {
if (charIndex > 0) {
dynamicText.textContent = roles[currentRoleIndex].substring(0, charIndex - 1);
charIndex--;
setTimeout(typeRole, erasingSpeed);
} else {
isDeleting = false;
currentRoleIndex = (currentRoleIndex + 1) % roles.length;
setTimeout(typeRole, typingSpeed);
}
} else {
if (charIndex < roles[currentRoleIndex].length) {
dynamicText.textContent += roles[currentRoleIndex].charAt(charIndex);
charIndex++;
setTimeout(typeRole, typingSpeed);
} else {
isDeleting = true;
setTimeout(typeRole, delayBetweenRoles);
}
}
}
document.addEventListener("DOMContentLoaded", () => {
setTimeout(typeRole, delayBetweenRoles);
});