-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (33 loc) · 801 Bytes
/
index.js
File metadata and controls
37 lines (33 loc) · 801 Bytes
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
$(document).ready(function () {
typing(0, $(".typewriter-text").data("text"));
function typing(index, text) {
var textIndex = 1;
var tmp = setInterval(function () {
if (textIndex < text[index].length + 1) {
$(".typewriter-text").text(text[index].substr(0, textIndex));
textIndex++;
} else {
setTimeout(function () {
deleting(index, text);
}, 2000);
clearInterval(tmp);
}
}, 150);
}
function deleting(index, text) {
var textIndex = text[index].length;
var tmp = setInterval(function () {
if (textIndex + 1 > 0) {
$(".typewriter-text").text(text[index].substr(0, textIndex));
textIndex--;
} else {
index++;
if (index == text.length) {
index = 0;
}
typing(index, text);
clearInterval(tmp);
}
}, 150);
}
});