alignment and now
This commit is contained in:
@@ -130,6 +130,7 @@
|
||||
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
||||
|
||||
import { formatZoned, getZonedHour } from '$lib/utils/date';
|
||||
import { useNow } from '$lib/utils/now.svelte';
|
||||
|
||||
import { CHART_COLORS } from './data';
|
||||
|
||||
@@ -224,6 +225,10 @@
|
||||
class: className = ''
|
||||
}: Props = $props();
|
||||
|
||||
// Minute-resolution clock shared with the rest of the app; read in draw() so
|
||||
// the current-time marker stays put as time passes.
|
||||
const clock = useNow();
|
||||
|
||||
// ─── Constants ──────────────────────────────────────────────────────────────
|
||||
|
||||
const PAD_BOTTOM = 34;
|
||||
@@ -1386,9 +1391,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Current time marker
|
||||
// Current time marker. Reading the shared clock (rather than Date.now())
|
||||
// makes the enclosing draw effect re-run every minute, so the line moves.
|
||||
if (showNow) {
|
||||
const now = Date.now() / 1000;
|
||||
const now = clock.current.getTime() / 1000;
|
||||
if (now >= viewStart && now <= viewEnd) {
|
||||
const x = xPix(now);
|
||||
ctx.strokeStyle = CHART_COLORS.currentTimeLine;
|
||||
|
||||
Reference in New Issue
Block a user