Files
gods-eye-view/src/ui/railTimeline.js
T
Sameh Khamis ce6040bde1 feat(ui): render the rail timeline as a component behind its builder
The observed-history transport is RailTimeline in src/ui/rail/, rendered
by createRailTimeline() with the same update and destroy API. Drag preview,
the coalesced 150 ms commit, release, cancel and blur behave as before; the
slider keeps the ticks it is dragged over, an update from inside a preview
cannot move the handle back, and readouts follow the handle within the same
task. utcClock moves to its own module and is still exported here.
2026-10-30 18:41:31 -07:00

57 lines
1.2 KiB
JavaScript

import { h, render } from 'vue';
import RailTimeline from './rail/RailTimeline.vue';
export { utcClock } from './rail/utcClock.js';
/**
* Stable native transport with local preview and a coalesced 150 ms drag
* commit. Renders the RailTimeline component into `container` and patches it
* synchronously on every update.
*/
export function createRailTimeline({
container,
document = container?.ownerDocument,
sliderClassName = '',
heading = true,
onCommit = () => {},
onPreview = () => {},
onStep = () => {},
onLatest = () => {},
onPlay = () => {},
} = {}) {
if (!document?.createElement || !container) return null;
let destroyed = false;
const paint = (state) =>
render(
h(RailTimeline, {
state,
sliderClassName,
heading,
onCommit,
onPreview,
onStep,
onLatest,
onPlay,
}),
container,
);
paint({
ticks: [],
index: 0,
mode: 'latest',
playing: false,
readout: '',
disabled: true,
});
return {
update(state) {
if (!destroyed) paint(state);
},
destroy() {
if (destroyed) return;
destroyed = true;
render(null, container);
},
};
}