-
Notifications
You must be signed in to change notification settings - Fork 0
/
eye.html
116 lines (97 loc) · 1.67 KB
/
eye.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
html, body, #app {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
#middle {
width: 1px;
height: 1px;
background-color: #000;
border-radius: 100px;
position: relative;
outline: 2px solid;
}
#search {
width: 1px;
height: 1px;
outline: 10px solid;
background-color: #000;
border-radius: 100px;
position: absolute;
}
.show {
animation-name: show;
animation-duration: 3s;
animation-fill-mode: forwards;
opacity: 1;
}
@keyframes show {
0% {
opacity: 1;
outline-width: 2px;
}
30% {
opacity: 1;
}
31% {
opacity: 0;
}
49% {
opacity: 0;
outline-width: 2px;
}
50% {
opacity: 1;
outline-width: 15px;
}
99% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#app {
background-color: #000;
}
#middle, #search {
background-color: #fff;
outline-color: #fff;
}
</style>
</head>
<body>
<div id="app">
<div id="middle">
<div id="search" class="show"></div>
</div>
</div>
<script>
const el = document.getElementById('search')
function getRandomArbitrary(min, max) {
// return 0
return Math.random() * (max - min) + min;
}
const run = () => {
console.log('x')
el.style.top = 92 + getRandomArbitrary(-15, 15) + 'px'
el.style.right = 144 + getRandomArbitrary(-15, 15) + 'px'
el.style.animation = 'none';
el.offsetHeight; /* trigger reflow */
el.style.animation = null;
const time = 3 * 1000 + getRandomArbitrary(0, 2000)
setTimeout(run, time)
}
run()
</script>
</body>
</html>