mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Weather rows play at the timeline's speed; the frame time shows under reduced motion; tidy the timeline's mark label
A weather row's play ran the world clock at whatever rate it had, and
going live set that back to 1, so the speed chosen on the timeline was
lost. The world clock now keeps its rate while paused and live, and the
timeline's speed sets it whenever it is chosen, so any play runs at it.
A row's play starts from the start of the covered time when live or at
its end, as the timeline's does, and does nothing while every product the
row shows is suspended, as its reduced-motion note says.
Live, the Weather panel's frame time is the newest of each product's
frames, suspended or not, so it no longer goes away under reduced motion,
on a hidden page or without an imagery host.
A weather layer made without a weather clock builds its own when first
enabled rather than when made, so a layer never turned on leaves the
world clock alone, and its own clock (createWeatherClock({ shared: false }))
leaves the world's time where it is when destroyed; only the last shared
weather clock sends the world live.
On the timeline, a zoom or a pan clears the hovered tick's label, a label
is never wider than the track and ends in an ellipsis, and a mark's label
is cut to 60 characters (WORLD_CLOCK_MARK_LABEL_LENGTH).
The changelog entry says what a row's step does, names the earthquake
layer's new exports and says it registers with the world clock.
This commit is contained in:
1 parent
558e4a919a
commit
620a337ce8
14 files changed
+351
-71
No files matched your search
@@ -96,7 +96,12 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
span: spanOf(state),
|
||||
});
|
||||
const time = shallowRef(read());
|
||||
const speed = shallowRef('real');
|
||||
// The speed the world clock keeps, where it is one of those offered.
|
||||
const speed = shallowRef(
|
||||
Object.keys(WORLD_TIME_SPEEDS).find(
|
||||
(key) => WORLD_TIME_SPEEDS[key] === worldClock.getRate(),
|
||||
) ?? 'real',
|
||||
);
|
||||
const rate = () => WORLD_TIME_SPEEDS[speed.value];
|
||||
let ticker = null;
|
||||
const syncTicker = () => {
|
||||
@@ -141,16 +146,16 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
},
|
||||
speed,
|
||||
/**
|
||||
* Choose how fast play runs; playing, it changes at once. A driver steps
|
||||
* at its own pace, so a speed chosen while one plays takes playback over
|
||||
* from where it is.
|
||||
* Choose how fast play runs: the world clock keeps it, so any play runs
|
||||
* at it (a layer's own Play too), and playing, it changes at once. A
|
||||
* driver steps at its own pace, so a speed chosen while one plays takes
|
||||
* playback over from where it is.
|
||||
*/
|
||||
setSpeed(next) {
|
||||
if (!Object.hasOwn(WORLD_TIME_SPEEDS, next)) return;
|
||||
speed.value = next;
|
||||
const { playing, stepping } = worldClock.getState();
|
||||
if (!playing) return;
|
||||
if (!stepping) return worldClock.setRate(rate());
|
||||
if (!playing || !stepping) return worldClock.setRate(rate());
|
||||
worldClock.pause();
|
||||
worldClock.play({ rate: rate(), continuous: true });
|
||||
},
|
||||
|
||||
@@ -135,7 +135,7 @@ body.cockpit-mode #world-timeline {
|
||||
}
|
||||
}
|
||||
|
||||
/* The track: ticks for each launch or frame, the elapsed fill, and a native
|
||||
/* The track: ticks for each launch or strong earthquake, the elapsed fill, and a native
|
||||
range input on top for dragging and the keyboard. */
|
||||
#world-timeline .world-timeline-track {
|
||||
position: relative;
|
||||
@@ -196,9 +196,14 @@ body.cockpit-mode #world-timeline {
|
||||
|
||||
/* A tick's label, shown over the time's bubble while the pointer is on the
|
||||
tick (or the handle rests on its mark). It slides across itself as the
|
||||
bubble does, so it stays within the track. */
|
||||
bubble does, so it stays within the track, and is never wider than the
|
||||
track: a long label ends in an ellipsis. */
|
||||
#world-timeline .world-timeline-mark-label {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
bottom: calc(100% + 30px);
|
||||
left: calc(100% * var(--at));
|
||||
z-index: 1;
|
||||
|
||||
@@ -669,3 +669,71 @@ test('a tick shows its label on hover, and a tap by it goes to its mark', async
|
||||
await nextTick();
|
||||
assert.equal(tip(), null);
|
||||
});
|
||||
|
||||
test('the pointer shows the nearer of two ticks within 6 px, and a zoom or a pan clears it', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 10 * 86_400_000;
|
||||
// Two ticks 8 px apart on a 1000 px track, at 200 and 208 px.
|
||||
const first = start + (now - start) * 0.2;
|
||||
const second = start + (now - start) * 0.208;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({
|
||||
start,
|
||||
end: now,
|
||||
marks: [
|
||||
{ time: first, label: 'FIRST', kind: 'launch' },
|
||||
{ time: second, label: 'SECOND', kind: 'launch' },
|
||||
],
|
||||
}),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
|
||||
const pointer = (type, clientX) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId: 1 }));
|
||||
const tip = () => bar().querySelector('.world-timeline-mark-label');
|
||||
// Where the first tick sits now, in px along the track.
|
||||
const firstAt = () =>
|
||||
Number.parseFloat(bar().querySelector('.world-timeline-tick').style.left) * 10;
|
||||
// The handle between them, so a zoom keeps both in view.
|
||||
worldClock.seek((first + second) / 2);
|
||||
await nextTick();
|
||||
pointer('pointermove', 203);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'FIRST');
|
||||
pointer('pointermove', 205);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'SECOND', 'the nearer of the two');
|
||||
|
||||
// A wheel zoom moves the ticks from under the pointer: the label goes.
|
||||
track.dispatchEvent(new WheelEvent('wheel', { deltaY: -200, cancelable: true }));
|
||||
await nextTick();
|
||||
assert.equal(track.classList.contains('is-zoomed'), true);
|
||||
assert.equal(tip(), null, 'a zoom clears the label');
|
||||
// So does a pan, by wheel or by drag.
|
||||
pointer('pointermove', firstAt());
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'FIRST');
|
||||
track.dispatchEvent(
|
||||
new WheelEvent('wheel', { deltaY: 40, shiftKey: true, cancelable: true }),
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(tip(), null, 'a pan clears the label');
|
||||
|
||||
// A tap between them goes to the nearer mark.
|
||||
track.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }));
|
||||
await nextTick();
|
||||
assert.equal(track.classList.contains('is-zoomed'), false);
|
||||
pointer('pointerdown', 205);
|
||||
pointer('pointerup', 205);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.now(), second, 'a tap goes to the nearer mark');
|
||||
});
|
||||
@@ -112,8 +112,10 @@ const view = computed(() => {
|
||||
});
|
||||
const zoomed = computed(() => zoom.value !== null);
|
||||
const viewLength = () => view.value.end - view.value.start;
|
||||
// Show `length` of the span ending at `viewEnd`, held to the span.
|
||||
// Show `length` of the span ending at `viewEnd`, held to the span. A zoom
|
||||
// or a pan moves the ticks from under the pointer, so its label goes.
|
||||
function showView(length, viewEnd) {
|
||||
hovered.value = null;
|
||||
const { start, end } = span.value;
|
||||
if (length >= end - start) {
|
||||
showWhole();
|
||||
@@ -141,6 +143,7 @@ const follow = (ms) => {
|
||||
};
|
||||
const offView = (ms) => ms < view.value.start || ms > view.value.end;
|
||||
const showWhole = () => {
|
||||
hovered.value = null;
|
||||
zoom.value = null;
|
||||
panned = false;
|
||||
};
|
||||
|
||||
+11
-3
@@ -118,9 +118,17 @@ export function createWeatherPanel({
|
||||
'weather-lightning': t('Lightning density'),
|
||||
};
|
||||
// While live, the newest frame and its age; at a past time, the timeline
|
||||
// time alone. The world timeline moves the time.
|
||||
const shownTime =
|
||||
state.mode === 'latest' ? state.timeline.at(-1) : state.target;
|
||||
// time alone. The world timeline moves the time. Live, each product's
|
||||
// newest frame counts, suspended or not (reduced motion, a hidden page),
|
||||
// as the timeline leaves those out.
|
||||
const newest = () => {
|
||||
const times = (state.products ?? [])
|
||||
.map(({ selected }) => selected)
|
||||
.filter((time) => Number.isFinite(Date.parse(time)))
|
||||
.sort((a, b) => Date.parse(a) - Date.parse(b));
|
||||
return times.at(-1) ?? state.timeline.at(-1);
|
||||
};
|
||||
const shownTime = state.mode === 'latest' ? newest() : state.target;
|
||||
const frameTime =
|
||||
showObserved && shownTime
|
||||
? state.mode === 'history'
|
||||
|
||||
@@ -86,10 +86,29 @@ test('the frame time shows with any observed product; the panel has no time cont
|
||||
view.update([wind, radar]);
|
||||
assert.equal(frameTime(f).hidden, false);
|
||||
assert.equal(frameTime(f).textContent, '01:05 UTC · 12 min ago');
|
||||
f.state({ timeline: [ticks[0]] });
|
||||
f.state({
|
||||
timeline: [ticks[0]],
|
||||
products: [{ id: radar.id, shown: ticks[0], selected: ticks[0] }],
|
||||
});
|
||||
assert.equal(frameTime(f).textContent, '01:00 UTC · 17 min ago');
|
||||
f.state({ timeline: [] });
|
||||
f.state({ timeline: [], products: [] });
|
||||
assert.equal(frameTime(f).hidden, true);
|
||||
// Suspended products (reduced motion, a hidden page) leave the timeline;
|
||||
// live, their newest frame still shows.
|
||||
f.state({
|
||||
timeline: [],
|
||||
products: [
|
||||
{ id: radar.id, shown: ticks[1], selected: ticks[1], suspended: true },
|
||||
{
|
||||
id: 'weather-lightning',
|
||||
shown: null,
|
||||
selected: ticks[0],
|
||||
suspended: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
assert.equal(frameTime(f).hidden, false);
|
||||
assert.equal(frameTime(f).textContent, '01:05 UTC · 12 min ago');
|
||||
f.state({ timeline: ticks, mode: 'history', target: ticks[0] });
|
||||
assert.equal(frameTime(f).textContent, '01:00 UTC');
|
||||
assert.equal(
|
||||
|
||||
Reference in new issue
Block a user