-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathportfolio.js
More file actions
38 lines (30 loc) · 1.04 KB
/
Copy pathportfolio.js
File metadata and controls
38 lines (30 loc) · 1.04 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
const words = ["Data Analyst", "Data Engineer", "Data Scientist", "Data Steward"]; // Words to replace
const wordElement = document.getElementById("word");
let currentIndex = 0;
function typeEffect() {
const currentWord = words[currentIndex];
const nextWord = words[(currentIndex + 1) % words.length];
// Delete the current word letter by letter
let i = currentWord.length;
const deleteInterval = setInterval(() => {
wordElement.textContent = currentWord.slice(0, i);
i--;
if (i < 0) {
clearInterval(deleteInterval);
// Type the new word letter by letter
let j = 0;
const typeInterval = setInterval(() => {
wordElement.textContent = nextWord.slice(0, j + 1);
j++;
if (j > nextWord.length) {
clearInterval(typeInterval);
currentIndex = (currentIndex + 1) % words.length;
// Restart the effect
setTimeout(typeEffect, 1000);
}
}, 150);
}
}, 150);
}
// Start the effect
typeEffect();