-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtyping.js
41 lines (32 loc) · 950 Bytes
/
typing.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
//jshint esversion: 6
var i = 0;
var txt = "Hey there ! I am Pratham a Web Developer.";
var speed = 100; /* The speed/duration of the effect in milliseconds */
function typeWriter() {
if (i < txt.length) {
if (i < 16) {
document.getElementById("effect1").innerHTML += txt.charAt(i);
i++;
} else if (i >= 16 && i < 24) {
document.getElementById("effect2").innerHTML += txt.charAt(i);
i++;
} else {
document.getElementById("effect3").innerHTML += txt.charAt(i);
i++;
}
setTimeout(typeWriter, speed);
}
}
setInterval(() => {
setTimeout(function() {
if (cursor) {
document.getElementById('cursor').innerHTML = "|";
document.getElementById('cursor').style.opacity = 0;
cursor = false;
} else {
document.getElementById('cursor').innerHTML = "|";
document.getElementById('cursor').style.opacity = 1;
cursor = true;
}
}, 3900);
}, 400);