Time scrubber

A ring buffer of DOM frames. Type in the note, tick some boxes, drag the cards about, then pull the slider back to see the interface as it was. "Restore this moment" puts the interface back to that frame, with its form values.

Note
Stopwatch
0.0
List
MoreOpen state is kept too.
Show the code recording and scrubbing DOM
  1. Put anything inside <dom-rewind>. Each child is recorded. data-x and data-y say where it starts.
  2. Seek, replay and restore. oncapture and onrestore carry state that lives in your script (here the stopwatch, sw). timeline is the range input.
  3. Inside the element: keep a snapshot whenever a child repaints. canvas.captureElementImage(el) returns an ElementImage, a frozen picture of the element that can be drawn later. The paint event's changedElements says which children need a new one.
  4. Inside the element: draw the past or the present. drawElementImage() takes an old snapshot or the live element. The live elements are drawn last, because the last draw decides where clicks land.
  5. The whole element.
LIVE

Use it

<script type="module" src="/lib/dom-rewind.js"></script>

<dom-rewind seconds="30" trails="6" style="height: 400px">
  <div data-x="20" data-y="20">…any HTML…</div>
</dom-rewind>

<script>
  const rw = document.querySelector('dom-rewind');
  rw.place(rw.children[0], { x: 120, y: 40, rotate: 0.1 });
  rw.seek(2.5);          // 2.5 s ago
  rw.restore();          // or rw.live()
  rw.oncapture = () => appState;        // optional: ride along with each frame
  rw.onrestore = (state) => { appState = state; };
</script>

Live checks

These run in your browser when this section is on screen, on the small fixtures in the box below. They don't touch the desk above.

test rig
A

Findings