-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
49 lines (43 loc) · 1.48 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
document.addEventListener("DOMContentLoaded", function(event) {
var typewriter = document.getElementById("typewriter");
var statements = [
" " ,
"E-Learning",
" Innovative",
" Real-world internships",
" Transformative learning",
" Accessible education"
];
var currentIndex = 0;
var isDeleting = false;
var typingSpeed = 200; // Speed of typing in milliseconds
var deletingSpeed = 100; // Speed of deleting in milliseconds
function typeNextCharacter() {
var currentText = typewriter.textContent;
var targetText = statements[currentIndex];
if (!isDeleting) {
typewriter.textContent = targetText.substring(0, currentText.length + 1);
if (currentText === targetText) {
isDeleting = true;
setTimeout(typeNextCharacter, deletingSpeed);
} else {
setTimeout(typeNextCharacter, typingSpeed);
}
} else {
typewriter.textContent = targetText.substring(0, currentText.length - 1);
if (currentText === "") {
isDeleting = false;
currentIndex++;
currentIndex %= statements.length;
setTimeout(typeNextCharacter, typingSpeed);
} else {
setTimeout(typeNextCharacter, deletingSpeed);
}
}
}
typeNextCharacter();
});
function scrollToAbout() {
const aboutSection = document.getElementById("about");
aboutSection.scrollIntoView({ behavior: "smooth" });
}