-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
45 lines (42 loc) · 1.14 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dream Machine</title>
<style id="style">
body {
transition: all 0.5s;
}
</style>
</head>
<body>
Rate
<br />
<input id="rate-slider" type="range" min="50" max="500" value="500" />
<br />
Fade
<br />
<input id="fade-slider" type="range" min="0" max="100" value="100" />
<script>
let rate = 500;
let on = false;
function step() {
on = !on;
document.body.style.background = on ? 'white' : 'black';
setTimeout(step, rate);
}
document.getElementById('rate-slider').oninput = (e) => {
rate = e.currentTarget.value;
};
document.getElementById('fade-slider').oninput = (e) => {
const duration = (e.currentTarget.value / 100) * (rate / 1000);
document.getElementById(
'style',
).innerHTML = `body {transition: all ${duration}s;}`;
};
step();
</script>
</body>
</html>