-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (47 loc) · 1.49 KB
/
Copy pathscript.js
File metadata and controls
61 lines (47 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
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let interval = null;
console.log("If you can see this message, I hope you know what you are doing!!!!")
const doc_h1 = document.querySelectorAll("h1")
for (let i = 0 ; i <doc_h1.length; i++) {
doc_h1[i].onmouseover = event => {
let iteration = 0;
clearInterval(interval);
interval = setInterval(() => {
event.target.innerText = event.target.innerText
.split("")
.map((letter, index) => {
if(index < iteration) {
return event.target.dataset.value[index];
}
return letters[Math.floor(Math.random() * 26)]
})
.join("");
if(iteration >= event.target.dataset.value.length){
clearInterval(interval);
}
iteration += 1 / 2.5;
}, 20);
}
}
// const doc = document.querySelectorAll("a")
// for (let i = 0; i < doc.length; i++) {
// doc[i].onmouseover = event => {
// let iteration = 0;
// clearInterval(interval);
// interval = setInterval(() => {
// event.target.innerText = event.target.innerText
// .split("")
// .map((letter, index) => {
// if(index < iteration) {
// return event.target.dataset.value[index];
// }
// return letters[Math.floor(Math.random() * 26)]
// })
// .join("");
// if(iteration >= event.target.dataset.value.length){
// clearInterval(interval);
// }
// iteration += 1 / 3;
// }, 30);
// }
// }