-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmasterjs.js
62 lines (52 loc) · 1.31 KB
/
masterjs.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
55
56
57
58
59
60
61
62
//links for redirect
function github_redirect() {
window.open('https://github.com/anomalousClasher');
}
function linkedin_redirect() {
window.open('https://www.linkedin.com/in/yin-hui-lee-2a2213261');
}
//typing effect
const carouselText = [
{ text: "data science student" },
{ text: "programmer" },
{ text: "coder" }
];
$(document).ready(async function () {
carousel(carouselText, "#feature-text");
});
async function typeSentence(sentence, eleRef, delay = 100) {
const letters = sentence.split("");
let i = 0;
while (i < letters.length) {
await waitForMs(delay);
$(eleRef).append(letters[i]);
i++;
}
return;
}
async function deleteSentence(eleRef) {
const sentence = $(eleRef).html();
const letters = sentence.split("");
let i = 0;
while (letters.length > 0) {
await waitForMs(100);
letters.pop();
$(eleRef).html(letters.join(""));
}
}
async function carousel(carouselList, eleRef) {
var i = 0;
while (true) {
await typeSentence(carouselList[i].text, eleRef);
await waitForMs(1500);
await deleteSentence(eleRef);
await waitForMs(500);
i++;
if (i >= carouselList.length) {
i = 0;
}
}
}
function waitForMs(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}