-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype-delete-sentences.html
55 lines (48 loc) · 1.61 KB
/
type-delete-sentences.html
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
<!-- HTML/JS com código que digita e apaga frases (inserido no widget de html) -->
<span id="resume-subtitle"></span>
<script>
const Type = async (words, elementId) => {
const htmlDom = document.getElementById(elementId);
const delay = (time = 0) => new Promise(resolve => setTimeout(resolve, time));
const eraser = async () => {
const wordOriginalLength = htmlDom.innerText.length;
for (let i = 0; i < wordOriginalLength; i++) {
await delay(40);
htmlDom.innerText = htmlDom.innerText.slice(0, -1);
}
};
const blinking = async (times) => {
for (let i = 0; i < times; i++) {
await delay(200);
htmlDom.innerText = htmlDom.innerText.endsWith("|")
? htmlDom.innerText.slice(0, -1)
: htmlDom.innerText + "|";
}
};
const writter = async (word) => {
const wordArray = word.split("");
for (let i = 0; i <= wordArray.length; i++) {
await delay(50);
if (i === wordArray.length) {
await blinking(11);
} else {
htmlDom.innerText = wordArray.slice(0, i).join("") + "|";
}
}
await eraser();
};
const init = async () => {
for (let i = 0; i < words.length; i++) {
await writter(words[i]);
}
};
await init();
await Type(words, elementId); // reinicia o loop
};
Type([
"Crie exemplos de headline para meu produto",
"Crie avatares de clientes para meus depoimentos",
"Melhore a qualidade dessas imagens em 8 vezes",
"Remova e troque o fundo dessas fotografias"
], "resume-subtitle");
</script>