mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
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.
57 lines
1.2 KiB
JavaScript
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);
|
|
},
|
|
};
|
|
}
|