-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
540 lines (470 loc) · 18.5 KB
/
index.html
File metadata and controls
540 lines (470 loc) · 18.5 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>NOTHING</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700;900&display=swap" rel="stylesheet" />
<style>
:root {
/* Slow, soft breathing (ms) */
--fade-in-ms: 2600; /* white → gray → dark gray */
--fade-out-ms: 1800; /* dark gray → gray → white */
--gap-ms: 0; /* no blank gap between lines */
--peak-opacity: 0.88; /* dark gray peak */
/* Stanza behavior */
--stanza-tail-mult: 1.8; /* “nothing” fade duration multiplier */
--stanza-tail-hold-ms: 800; /* extra time “nothing” stays before fading */
--stanza-gap-ms: 0; /* no explicit blank at BREAK */
/* Holds */
--first-hold-ms: 700; /* first line tiny hold */
--thanks-hold-ms: 900; /* last line tiny hold */
/* Middles: slightly quicker exit feel */
--middle-fade-out-mult: 0.85;
/* Promos (end cards) */
--promo-link-hold-ms: 1200;
--october-hold-ms: 200;
--promo-fade-out-mult: 0.7;
/* End-of-cycle white hold */
--end-white-hold-ms: 3000;
/* link styling */
--link-color: #6b7280;
--link-hover: #111827;
}
html, body {
height: 100%;
margin: 0;
background: white;
color: black;
overflow: hidden;
overscroll-behavior: none;
}
body {
position: fixed;
inset: 0;
height: 100dvh;
display: grid;
place-items: center;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
touch-action: none;
user-select: none;
-webkit-user-select: none;
}
#line {
font-family: "Roboto", "Helvetica Neue", Arial, sans-serif;
font-weight: 900;
font-size: clamp(28px, 8vw, 64px);
line-height: 1.15;
text-align: center;
max-width: min(90vw, 1200px);
color: #000;
opacity: 0;
}
.token { transition-property: opacity; }
.rest { opacity: 1; }
.nothing { opacity: 1; }
#line a {
color: var(--link-color);
text-decoration: none;
cursor: pointer;
pointer-events: auto;
}
#line a:hover, #line a:focus-visible { color: var(--link-hover); }
#line a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) {
#line, .token { transition: none !important; opacity: 1 !important; }
}
</style>
</head>
<body>
<div id="line" aria-live="polite"></div>
<script>
/* ---------------- Content ---------------- */
const BREAK = "__BREAK__"; // stanza separator
const items = [
// Stanza 1
`Nothing to see here.`,
`Less than nothing.`,
`A whole lotta nothing.`,
`A big fat nothingburger.`,
`Nothing but dead air.`,
`Nothing to write home about.`,
`Practically nothing.`,
`I won’t settle for nothing.`,
BREAK,
// Stanza 2
`Make something out of nothing?`,
`Nothing ventured, nothing gained.`,
`Leave nothing to chance.`,
`I have nothing to lose.`,
`Next to nothing.`,
`Close to nothing.`,
`Better than nothing.`,
`Leave nothing on the table.`,
`Accept nothing less.`,
BREAK,
// Stanza 3
`There’s nothing to it.`,
`Nothing compares.`,
`Sweet nothings.`,
`Leave nothing to the imagination.`,
`Nothing short of a miracle.`,
`Nothing to sneeze at.`,
`Nothing else matters.`,
`Nothing but the best.`,
`Nothing but blue skies.`,
`Nothing can stop us.`,
`There’s nothing like it.`,
`Double or nothing?`,
`All or nothing.`,
BREAK,
// Stanza 4
`Much ado about nothing.`,
`Nothing to worry about.`,
`Nothing worth having comes easy.`,
`Think nothing of it.`,
`It signifies nothing.`,
`Nothing of the sort.`,
`You have nothing to fear.`,
`There’s nothing between us.`,
`Nothing could be further from the truth.`,
`I’ve got nothing to declare.`,
`Nothing to hide.`,
`Nothing to say.`,
`Say nothing.`,
`You’ve got nothing on me.`,
BREAK,
// Stanza 5
`Nothing but the truth.`,
`Leave nothing out.`,
BREAK,
// Stanza 6
`Nothing ever goes as planned.`,
`Nothing short of a disaster.`,
`Nothing good happens after 2AM.`,
`Nothing but trouble.`,
`There’s nothing between us.`,
BREAK,
// Stanza 7
`Is nothing sacred?`,
`You’ve given me nothing but smoke and mirrors.`,
`Nothing but empty promises.`,
BREAK,
// Stanza 8
`You can’t expect something for nothing.`,
`Nothing is free.`,
`Nothing lasts forever.`,
`It’s nothing personal.`,
BREAK,
// Stanza 9
`You are good for nothing.`,
`I’ve got nothing in the tank.`,
`Nothing to show for it.`,
`Nothing but skin and bones.`,
`Nothing but the shirt on my back.`,
`This was all for nothing.`,
`It amounts to nothing.`,
`It’s worth nothing.`,
`I’ve got nothing.`,
`You are nothing.`,
`Thanks for nothing.`,
// Promos
{ text: 'AiOP 2025 NOTHING', href: 'https://nothing.artinoddplaces.org/' },
{ text: 'October 18-19' },
{ text: 'DAVIDDARTS.COM', href: 'https://daviddarts.com' },
];
const el = document.getElementById('line');
/* ---------------- Timings ---------------- */
const css = getComputedStyle(document.documentElement);
const fadeInMs = parseInt(css.getPropertyValue('--fade-in-ms')) || 2600;
const fadeOutMs = parseInt(css.getPropertyValue('--fade-out-ms')) || 1800;
const gap = parseInt(css.getPropertyValue('--gap-ms')) || 0;
const peakOpacity = Math.min(1, Math.max(0, parseFloat(css.getPropertyValue('--peak-opacity')) || 0.88));
const stanzaTailMult = parseFloat(css.getPropertyValue('--stanza-tail-mult')) || 1.8;
const stanzaTailHold = parseInt(css.getPropertyValue('--stanza-tail-hold-ms')) || 800;
const stanzaGapMs = parseInt(css.getPropertyValue('--stanza-gap-ms')) || 0;
const firstHoldMs = parseInt(css.getPropertyValue('--first-hold-ms')) || 700;
const thanksHoldMs = parseInt(css.getPropertyValue('--thanks-hold-ms')) || 900;
const middleFadeOutMult = parseFloat(css.getPropertyValue('--middle-fade-out-mult')) || 0.85;
const nothingFadeMultFirstLast = 1.8;
// promos
const promoLinkHold = parseInt(css.getPropertyValue('--promo-link-hold-ms')) || 1200;
const octoberHold = parseInt(css.getPropertyValue('--october-hold-ms')) || 200;
const promoFadeOutMult = parseFloat(css.getPropertyValue('--promo-fade-out-mult')) || 0.7;
const endWhiteHoldMs = parseInt(css.getPropertyValue('--end-white-hold-ms')) || 3000;
/* ---------------- Tokenization ---------------- */
const NOTHING_SPLIT = /(nothing)s?/gi;
const NOTHING_TEST = /nothing/i;
const isObj = (item) => typeof item === 'object' && item !== null;
const isLinkItem = (item) => isObj(item) && 'href' in item;
const isBreak = (item) => item === BREAK;
function renderItemToHTML(item) {
if (isLinkItem(item)) {
return `<a href="${item.href}" target="_blank" rel="noopener noreferrer">${item.text}</a>`;
}
const text = isObj(item) ? item.text : String(item);
const parts = text.split(NOTHING_SPLIT);
let html = '';
for (let idx = 0; idx < parts.length; idx++) {
const part = parts[idx];
if (!part) continue;
if (/^nothing$/i.test(part)) {
html += `<span class="token nothing">${part}</span>`;
} else if (/^nothings$/i.test(part)) {
html += `<span class="token nothing">nothing</span><span class="token rest">s</span>`;
} else {
html += `<span class="token rest">${part}</span>`;
}
}
return html;
}
function lineHasNothing(item) {
if (isLinkItem(item) || isBreak(item)) return false;
const text = isObj(item) ? item.text : String(item);
return NOTHING_TEST.test(text);
}
/* ---------------- Helpers ---------------- */
function animateOnce(el, keyframes, options) {
if (!el.animate) {
Object.assign(el.style, { opacity: keyframes[keyframes.length - 1].opacity });
return Promise.resolve();
}
const anim = el.animate(keyframes, options);
return new Promise(resolve => anim.addEventListener('finish', resolve, { once: true }));
}
let i = 0;
let autoplay = true;
let timers = new Set();
let resumeTimer = null;
let cycling = false;
let resumeAdvanceNext = false;
let skipNextBreak = false; // skip the BREAK after a stanza tail
function schedule(fn, ms) {
const id = setTimeout(() => { timers.delete(id); fn(); }, ms);
timers.add(id);
return id;
}
function clearTimers() { timers.forEach(id => clearTimeout(id)); timers.clear(); }
function cancelAllAnimations() {
try { (document.getAnimations?.() || []).forEach(a => a.cancel()); } catch {}
}
function pauseAndScheduleResume({ advanceOnResume = true } = {}) {
autoplay = false;
resumeAdvanceNext = advanceOnResume;
if (resumeTimer) clearTimeout(resumeTimer);
resumeTimer = setTimeout(() => {
autoplay = true;
if (resumeAdvanceNext) { i = (i + 1) % items.length; resumeAdvanceNext = false; }
cycle(true);
}, 4000);
}
function holdForItem(idx, item) {
if (isLinkItem(item)) return promoLinkHold;
if (isObj(item) && item.text === 'October 18-19') return octoberHold;
if (idx === 0) return firstHoldMs;
if (typeof item === 'string' && item === 'Thanks for nothing.') return thanksHoldMs;
return 0;
}
function fadeOutDuration(idx, item, isMiddlePoemLine) {
if (isLinkItem(item) || (isObj(item) && item.text === 'October 18-19')) {
return Math.round(fadeOutMs * promoFadeOutMult);
}
if (isMiddlePoemLine) return Math.round(fadeOutMs * middleFadeOutMult);
return fadeOutMs;
}
/* ---------------- Core show/cycle ---------------- */
async function showIndex(idx, { skipHoldForMiddle = false } = {}) {
const item = items[idx];
// break items are skipped; stanza rhythm handled by tail effect
if (isBreak(item)) {
el.innerHTML = '';
el.style.opacity = '0';
if (stanzaGapMs > 0) {
await new Promise(resolve => { schedule(resolve, stanzaGapMs); });
}
return;
}
const nextItem = items[(idx + 1) % items.length];
const nextIsBreak = isBreak(nextItem);
const isFirst = idx === 0;
const isThanks = (typeof item === 'string' && item === 'Thanks for nothing.');
const isLink = isLinkItem(item);
const isOctober = isObj(item) && item.text === 'October 18-19';
const isDAVID = isObj(item) && item.text === 'DAVIDDARTS.COM';
const isMiddlePoemLine = !isFirst && !isThanks && !isLink && !isOctober;
const holdMs = holdForItem(idx, item);
const fadeOutThis = fadeOutDuration(idx, item, isMiddlePoemLine);
// Render
el.innerHTML = renderItemToHTML(item);
// Fade in (0 → peakOpacity)
el.style.opacity = '0';
await Promise.resolve();
await animateOnce(el, [{ opacity: 0 }, { opacity: peakOpacity }], {
duration: fadeInMs,
easing: 'cubic-bezier(0.2, 0, 0, 1)',
fill: 'forwards'
});
// Optional brief hold
if (holdMs > 0 && !(skipHoldForMiddle && isMiddlePoemLine)) {
await new Promise(resolve => { schedule(resolve, holdMs); });
}
// Fade out behavior
if (isFirst || isThanks) {
// first/last: rest fades, “nothing” lingers longer
const rest = el.querySelectorAll('.rest');
const nothing = el.querySelectorAll('.nothing');
rest.forEach(t => {
t.style.transitionProperty = 'opacity';
t.style.transitionTimingFunction = 'ease-in-out';
t.style.transitionDuration = `${fadeOutThis}ms`;
t.style.opacity = '0';
});
const nothingDur = Math.round(fadeOutThis * nothingFadeMultFirstLast);
nothing.forEach(t => {
t.style.transitionProperty = 'opacity';
t.style.transitionTimingFunction = 'ease-in-out';
t.style.transitionDuration = `${nothingDur}ms`;
t.style.opacity = '0';
});
await new Promise(resolve => { schedule(resolve, nothingDur + gap); });
el.style.opacity = '0';
} else if (nextIsBreak && lineHasNothing(item)) {
// stanza tail: 1) fade rest, 2) hold “nothing”, 3) fade “nothing”
const rest = el.querySelectorAll('.rest');
const nothing = el.querySelectorAll('.nothing');
// Stage 1: rest fades out over fadeOutThis
rest.forEach(t => {
t.style.transitionProperty = 'opacity';
t.style.transitionTimingFunction = 'ease-in-out';
t.style.transitionDuration = `${fadeOutThis}ms`;
t.style.opacity = '0';
});
// Wait for rest fade to finish
await new Promise(resolve => { schedule(resolve, fadeOutThis); });
// Stage 1.5: hold “nothing” visible a bit longer
if (stanzaTailHold > 0) {
await new Promise(resolve => { schedule(resolve, stanzaTailHold); });
}
// Stage 2: fade “nothing” itself
const nothingDur = Math.round(fadeOutThis * stanzaTailMult);
nothing.forEach(t => {
t.style.transitionProperty = 'opacity';
t.style.transitionTimingFunction = 'ease-in-out';
t.style.transitionDuration = `${nothingDur}ms`;
t.style.opacity = '0';
});
await new Promise(resolve => { schedule(resolve, nothingDur + gap); });
el.style.opacity = '0';
// Skip the BREAK that follows this line
skipNextBreak = true;
} else {
// Middle or promo: fade container
await animateOnce(el, [{ opacity: peakOpacity }, { opacity: 0 }], {
duration: fadeOutThis,
easing: 'ease-in-out',
fill: 'forwards'
});
if (isDAVID) {
await new Promise(resolve => { schedule(resolve, endWhiteHoldMs); });
} else if (gap > 0) {
await new Promise(resolve => { schedule(resolve, gap); });
}
}
}
async function cycle(forceStart = false) {
if (!forceStart && (!autoplay || cycling)) return;
cycling = true;
while (autoplay) {
clearTimers();
await showIndex(i);
i = (i + 1) % items.length;
// Skip the BREAK immediately after a stanza tail effect
if (skipNextBreak && isBreak(items[i])) {
i = (i + 1) % items.length;
}
skipNextBreak = false;
}
cycling = false;
}
/* ---------------- Manual navigation ---------------- */
function jumpBy(step) {
pauseAndScheduleResume({ advanceOnResume: true });
clearTimers();
cancelAllAnimations();
i = (i + step + items.length) % items.length;
el.style.opacity = '0';
showIndex(i, { skipHoldForMiddle: true });
}
// Swipe/click (horizontal), plus left/right click zones
let tracking = null;
const AXIS_LOCK_RATIO = 1.2;
const MIN_VELOCITY = 0.35; // px/ms
const SWIPE_PX = 35;
function now() { return performance.now(); }
function beginTrack(e) {
if (tracking) return;
tracking = { id: e.pointerId, startX: e.clientX, startY: e.clientY, lastX: e.clientX, lastY: e.clientY, startT: now() };
}
function moveTrack(e) {
if (!tracking || e.pointerId !== tracking.id) return;
tracking.lastX = e.clientX; tracking.lastY = e.clientY;
}
function endTrack(e) {
if (!tracking || e.pointerId !== tracking.id) return;
const dt = Math.max(1, now() - tracking.startT);
const dx = tracking.lastX - tracking.startX, dy = tracking.lastY - tracking.startY;
const ax = Math.abs(dx), ay = Math.abs(dy);
const vx = ax / dt;
const isHorizontal = ax > ay * AXIS_LOCK_RATIO;
const passed = ax > SWIPE_PX || vx > MIN_VELOCITY;
const link = e.target.closest && e.target.closest('a');
tracking = null;
if (link) return;
if (isHorizontal && passed) jumpBy(dx < 0 ? +1 : -1);
}
function onClick(e) {
const link = e.target.closest && e.target.closest('a');
if (link) return;
const mid = window.innerWidth / 2;
const dir = (e.clientX >= mid) ? +1 : -1; // right = forward, left = backward
jumpBy(dir);
}
function onKey(e) { if (e.key === 'ArrowRight') jumpBy(+1); else if (e.key === 'ArrowLeft') jumpBy(-1); }
document.addEventListener('touchmove', (e) => {
const onLink = e.target.closest && e.target.closest('a');
if (!onLink) e.preventDefault();
}, { passive: false });
/* ---------------- Kickoff ---------------- */
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
const first = items.find(it => !isBreak(it));
el.textContent = typeof first === 'string' ? first : first.text;
el.style.opacity = '1';
} else {
cycle(true);
document.addEventListener('pointerdown', beginTrack, { passive: true });
document.addEventListener('pointermove', moveTrack, { passive: true });
document.addEventListener('pointerup', endTrack, { passive: true });
document.addEventListener('pointercancel', () => { tracking = null; }, { passive: true });
document.addEventListener('click', onClick);
document.addEventListener('keydown', onKey);
}
// Favicon
(function setFavicon() {
const svg =
`<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
<rect x="8" y="8" width="48" height="48" fill="#fff" stroke="#000" stroke-width="4" rx="6" ry="6"/>
</svg>`;
const href = "data:image/svg+xml," + encodeURIComponent(svg) + "#v=" + Date.now();
document.querySelectorAll('link[rel="icon"]').forEach(n => n.remove());
const link = document.createElement('link');
link.rel = 'icon';
link.type = 'image/svg+xml';
link.href = href;
document.head.appendChild(link);
})();
</script>
</body>
</html>