-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
54 lines (45 loc) · 1.52 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
document.addEventListener("DOMContentLoaded", function () {
const words = ["Web Developer", "Web Designer", "Frontend Developer"];
let wordIndex = 0;
let charIndex = 0;
let currentWord = '';
const typingSpeed = 100;
const erasingSpeed = 50;
const newWordDelay = 2000;
function type() {
if (charIndex < words[wordIndex].length) {
currentWord += words[wordIndex].charAt(charIndex);
document.querySelector('.typing-animation').textContent = currentWord;
charIndex++;
setTimeout(type, typingSpeed);
} else {
setTimeout(erase, newWordDelay);
}
}
function erase() {
if (charIndex > 0) {
currentWord = currentWord.slice(0, -1);
document.querySelector('.typing-animation').textContent = currentWord;
charIndex--;
setTimeout(erase, erasingSpeed);
} else {
wordIndex = (wordIndex + 1) % words.length;
setTimeout(type, typingSpeed + 1100);
}
}
type();
});
// Animate progress bars
const progressBars = document.querySelectorAll('.progress-done');
progressBars.forEach(bar => {
setTimeout(() => {
bar.style.width = bar.getAttribute('data-done') + '%';
bar.style.opacity = 1;
}, 500);
});
// Animate circular skills
const circles = document.querySelectorAll('.circle');
circles.forEach(circle => {
let percent = circle.getAttribute('data-percent');
circle.style.setProperty('--percent', percent);
});