Timeline marks carry labels; a tap by a tick goes to its mark

A layer's world clock coverage may now give each mark as an object,
{ time, label?, id?, kind? }, as well as a bare epoch ms number, and the
two may be mixed. worldClock.coverage() keeps marks as the sorted list of
distinct times, so existing readers are unchanged, and adds markDetails:
the merged marks in time order (then kind, label and id), each frozen and
holding only the fields given. Marks given alike by several sources appear
once, a bare time is dropped where a labelled mark shares it, and a mark
with no finite time is ignored. The contract is documented in the
worldClock JSDoc and docs/APPLICATION.md.

Launches label their marks with the mission's name (the launch's where it
has none), cut to 27 characters in capitals as the mission index shows
names. Earthquakes of magnitude 6 and up label theirs with the magnitude
as the map shows it and the feed's place cut to 40 characters, such as
"M6.4 · 113 km SSE of Lata, Solomon Islands"; the layer now tells the clock
when the labels change as well as the times.

On the timeline, a pointer within 6 px of a tick shows its label over the
track (nothing for an unlabelled mark), and a tap there goes exactly to
the mark's time instead of the point tapped. A tap elsewhere and a drag
work as before, and ticks stay ticks. The arrow keys still step from mark
to mark; with the handle on a mark, its labels follow the time in the
handle's aria-valuetext, and show over the track while it has focus.
This commit is contained in:
Sameh Khamis committed 2026-11-14 20:30:01 -08:00
1 parent 7cb854c923
commit 558e4a919a
17 files changed
+490 -50

No files matched your search

@@ -581,3 +581,91 @@ test('a pinch measures from where the fingers are, and a lifted finger ends it',
assert.ok(Math.abs(length() - zoomedTo) < 1_000);
on(input, 'pointercancel', 100, 1);
});
test('a tick shows its label on hover, and a tap by it goes to its mark', async (t) => {
const bar = mount(t);
const now = Date.now();
const start = now - 10 * 86_400_000;
// Ticks a fifth and seven tenths along a 1000 px track.
const launch = start + (now - start) * 0.2;
const quake = start + (now - start) * 0.7;
const release = worldClock.hold('test-launches');
const unregister = worldClock.register({
id: 'test-launches',
coverage: () => ({
start,
end: now,
marks: [
start,
{ time: launch, label: 'GAUNTLET PAYLOAD', id: 'l1', kind: 'launch' },
{ time: quake, label: 'M6.4 · Fiji', kind: 'earthquake' },
],
}),
});
t.after(() => {
unregister();
release();
});
await nextTick();
const track = bar().querySelector('.world-timeline-track');
const input = bar().querySelector('input[type=range]');
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
const press = (type, clientX, pointerId = 1) =>
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId }));
const tip = () => bar().querySelector('.world-timeline-mark-label');
assert.equal(bar().querySelectorAll('.world-timeline-tick').length, 3, 'ticks stay ticks');
assert.equal(tip(), null);
// Hovering within 6 px of a tick shows its label, in place of the track's hint.
press('pointermove', 205);
await nextTick();
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
assert.equal(track.hasAttribute('title'), false);
press('pointermove', 698);
await nextTick();
assert.equal(tip()?.textContent, 'M6.4 · Fiji');
// Further off, or on a tick with no label, nothing shows.
press('pointermove', 690);
await nextTick();
assert.equal(tip(), null);
assert.equal(track.hasAttribute('title'), true);
press('pointermove', 2);
await nextTick();
assert.equal(tip(), null, 'an unlabelled mark has no label');
press('pointermove', 205);
track.dispatchEvent(new PointerEvent('pointerleave', { clientX: 1_100, pointerId: 1 }));
await nextTick();
assert.equal(tip(), null, 'leaving the track hides it');
// A tap by a tick goes to its mark exactly; elsewhere, to the time there.
press('pointerdown', 704);
press('pointerup', 704);
await nextTick();
assert.equal(worldClock.now(), quake);
assert.match(input.getAttribute('aria-valuetext'), / · M6\.4 · Fiji$/);
press('pointerdown', 500);
press('pointerup', 500);
await nextTick();
const middle = start + (now - start) / 2;
assert.ok(Math.abs(worldClock.now() - middle) < 60_000, 'went to the middle');
assert.notEqual(worldClock.now(), quake);
assert.match(input.getAttribute('aria-valuetext'), /UTC$/, 'off a mark, the time alone');
// A drag from a tick still scrubs.
press('pointerdown', 200);
press('pointermove', 300);
press('pointerup', 300);
await nextTick();
assert.ok(Math.abs(worldClock.now() - (start + (now - start) * 0.3)) < 60_000);
// The arrows go to the marks and tell their labels; focused, the label shows.
input.dispatchEvent(new Event('focus'));
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft' }));
await nextTick();
assert.equal(worldClock.now(), launch);
assert.match(input.getAttribute('aria-valuetext'), / · GAUNTLET PAYLOAD$/);
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
input.dispatchEvent(new Event('blur'));
await nextTick();
assert.equal(tip(), null);
});