-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
178 lines (167 loc) · 4.44 KB
/
index.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
<style>
html {
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
}
.bg {
position: fixed;
height: 100%;
width: 100%;
background: linear-gradient(-45deg, #f5b23f, #3cc8e7, #d8f931, #26e6b9);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
top: 0;
left: 0;
z-index: -1;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
.text-container {
position: relative;
display: inline-block;
top: 100px;
left: 40px;
}
.text {
cursor: default;
position: relative;
color: #fff;
line-height: 50px;
font-weight: bold;
font-size: 50px;
font-family: 'Courier New';
user-select: none;
-webkit-user-select: none;
}
.text-bg {
background-color: rgba(0, 0, 0, 0.2);
padding: 5px;
}
.spotlight {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background: radial-gradient(
50px 50px at center center,
transparent,
transparent 100px,
rgba(0, 0, 0, 0.05) 150px
);
opacity: 1;
z-index: 1;
}
.traffic-light-area {
display: block;
height: 30px;
width: 62px;
background: #0000007e;
user-select: none;
position: fixed;
top: 0;
left: 0;
right: 0;
padding-left: 10px;
border-radius: 0 0 5px 0;
}
</style>
</head>
<body>
<!-- <div class="traffic-light-area"></div> -->
<div id="spotlight" class="spotlight"></div>
<div class="text-container">
<span id="text-prefix" class="text">Hello </span>
<span id="text-name" class="text text-bg"></span>
<span id="cursor" class="text">_</span>
</div>
<div class="bg"></div>
<script>
/* Spotlight */
const spotlightEl = document.getElementById('spotlight');
function handleMouseMove(event) {
const { clientX, clientY } = event;
spotlightEl.style =
'background:radial-gradient(50px 50px at ' +
clientX +
'px ' +
clientY +
'px, transparent, transparent 100px, rgba(0,0,0,0.05) 150px)';
}
document.addEventListener('mousemove', handleMouseMove);
/* Typing Effect */
async function startCarosel() {
const textNameEl = document.getElementById('text-name');
const texts = ['Verso.', 'Servo.', 'World!'];
const colors = ['#ffc131', '#3cc8e7', '#ffffff'];
let textIdx = 0;
while (true) {
const text = texts[textIdx];
updateNameColor(textNameEl, colors[textIdx]);
await type(texts[textIdx], textNameEl);
let blinkTimerId = blinkCursor();
await sleep(3200);
cleanCursor(blinkTimerId);
await backspace(textNameEl);
await sleep(500);
textIdx = (textIdx + 1) % texts.length;
}
}
async function type(text, el, delay = 100) {
el.classList.add('text-bg');
for (const ch of text) {
await sleep(delay);
el.innerHTML += ch;
}
}
async function backspace(el) {
let text = el.innerHTML;
while (text.length > 0) {
await sleep(60);
text = text.slice(0, -1);
el.innerHTML = text;
}
el.classList.remove('text-bg');
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function blinkCursor() {
const cursor = document.getElementById('cursor');
return setInterval(() => {
if (cursor.innerHTML === '_') {
cursor.innerHTML = '';
} else {
cursor.innerHTML = '_';
}
}, 500);
}
function cleanCursor(timerId) {
clearTimeout(timerId);
const cursor = document.getElementById('cursor');
cursor.innerHTML = '_';
}
function updateNameColor(el, color) {
el.style.color = color;
}
startCarosel();
</script>
</body>
</html>