-
Notifications
You must be signed in to change notification settings - Fork 2
/
efeito-maquina-de-escrever-origamid.html
67 lines (58 loc) · 1.4 KB
/
efeito-maquina-de-escrever-origamid.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
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>TypeWriter</title>
</head>
<body>
<style>
body {
background: #0e1013;
}
h1 {
max-width: 480px;
text-align: center;
margin: 60px auto;
font-family: 'Courier New', Courier, monospace;
color: #fff;
}
h1::after {
content: '|';
opacity: 1;
margin-left: 5px;
display: inline-block;
animation: blink .7s infinite;
}
@keyframes blink {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
</style>
<h1>Cursos de UX/UI Design e Front End na Origamid</h1>
<script>
function typeWriter(elemento) {
const textoArray = elemento.innerHTML.split('');
elemento.innerHTML = '';
textoArray.forEach((letra, i) => {
setTimeout(() => elemento.innerHTML += letra, 75 * i);
});
}
// Se estiver tendo problemas com performance, utilize o FOR loop como abaixo no local do forEach
// function typeWriter(elemento) {
// const textoArray = elemento.innerHTML.split('');
// elemento.innerHTML = '';
// for(let i = 0; i < textoArray.length; i++) {
// setTimeout(() => elemento.innerHTML += textoArray[i], 75 * i);
// }
// }
const titulo = document.querySelector('h1');
typeWriter(titulo);
</script>
</body>
</html>