-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
108 lines (96 loc) · 2.37 KB
/
index.html
File metadata and controls
108 lines (96 loc) · 2.37 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
/>
<title>AsciiDance dist test</title>
<style>
:root {
color-scheme: dark;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
display: grid;
min-height: 100vh;
background: #0a1118;
color: #cdd5de;
font-family:
system-ui,
-apple-system,
sans-serif;
}
main {
display: grid;
grid-template-rows: auto 1fr;
}
header {
display: flex;
gap: 12px;
align-items: center;
padding: 12px 16px;
background: rgba(10, 17, 24, 0.85);
backdrop-filter: blur(6px);
position: sticky;
top: 0;
z-index: 1;
}
button {
padding: 6px 12px;
border-radius: 6px;
border: 1px solid #2a3a4a;
background: #15202b;
color: inherit;
cursor: pointer;
}
button:hover {
background: #1b2835;
}
canvas {
width: 100%;
height: 100%;
display: block;
}
</style>
</head>
<body>
<main>
<header>
<div><strong>AsciiDance</strong> dist smoke test</div>
<button id="toggle">Pause</button>
</header>
<canvas id="ascii" aria-label="AsciiDance canvas"></canvas>
</main>
<script type="module">
import { AsciiDance, DEFAULTS } from './dist/index.js'
const canvas = document.getElementById('ascii')
const toggleBtn = document.getElementById('toggle')
const field = new AsciiDance(canvas, { ...DEFAULTS, sizeMode: 'window' })
field.start()
let running = true
toggleBtn.addEventListener('click', () => {
running = !running
toggleBtn.textContent = running ? 'Pause' : 'Resume'
if (running) {
field.start()
} else {
field.stop()
}
})
// Be kind to background tabs / navigation
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
field.stop()
} else if (running) {
field.start()
}
})
window.addEventListener('beforeunload', () => field.destroy())
</script>
</body>
</html>