-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexScripts.js
More file actions
62 lines (54 loc) · 1.49 KB
/
indexScripts.js
File metadata and controls
62 lines (54 loc) · 1.49 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//Sets the speed in mili seconds between each char;
let typeSpeed = 200;
//Sets the data to be type
let title = "$Callum Gilchrist"; //Title
let subtitle = "";
let typedTitle = "";
let notSkipped = true;
let stage = 0;
//Makes the data to be typedTitle usable with pop() by converting it to an array and reversing it.
title = title.split("").reverse();
async function typeName() {
//Ignores timer for single spaces.
if (notSkipped) {
if (title[title.length - 1] == " ") {
typedTitle += title.pop();
}
typedTitle += title.pop();
} else {
while (title.length > 0) {
typedTitle += title.pop()
}
}
//Writes to the heading.
$("#NameTitle").text(typedTitle);
//If not at the end of the line, call the function again to print all the next letters.
if (title.length !== 0) {
setTimeout(typeName, typeSpeed);
//Once the end of a line is reached print the next line if there is one.
} else {
fadeInPage();
}
}
async function fadeInPage() {
$("#nav-placeholder").load("navbar.html");
if (notSkipped) {
$("#SubTitle").fadeIn(3000);
$("#nav-placeholder").fadeIn(3000);
$("#spiro").fadeIn(3000);
} else {
$("#SubTitle").fadeIn(0);
$("#nav-placeholder").fadeIn(0);
$("#spiro").fadeIn(0);
}
}
//If user presses any key skip the animation
window.addEventListener("keydown", (event) => {
if (event.isComposing || event.keyCode === 229) {
return;
}
// do something
notSkipped = false;
});
$("#spiro").hide();
typeName();