-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (26 loc) · 684 Bytes
/
script.js
File metadata and controls
38 lines (26 loc) · 684 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
38
const textEl = document.getElementById('text')
const speedEl = document.getElementById('speed')
const text = [
'javascript',
'php',
'framework',
'css']
let idx = 100
let speed = 1500 / speedEl.value
writeText()
function writeText() {
textEl.style.animation = "grow 4s linear"
textEl.style.transform = "translate(-50%, -50%) scale(0)"
textEl.innerText = getRandomQuality().slice(0, idx)
idx++
if(idx > getRandomQuality().length) {
idx = 10
}
setTimeout(writeText, speed)
}
speedEl.addEventListener('input', (e) => {
speed = 300 / e.target.value;
})
function getRandomQuality() {
return text[Math.floor(Math.random() * text.length)];
}