Partial updates and moved elements drawn by a canvas

The tiles below are children of a canvas. Four of them hold a named range, <?start name="orders"?> to <?end?>. A stream of <template for="orders"> elements replaces each range, in any order, with no script touching the tiles. The canvas draws every tile as its own texture, so it can show which tile a patch is landing in, and it can fly a tile from its old place to its new one when moveBefore() reorders the list.

Orders today

Clock hand

A CSS animation.

Note

Focus this, then shuffle.

Build

Top pages

On call

 

 

Show the code ranges, patches, one texture per tile, moves
  1. Ranges and a marker in the markup. Each tile is a drawable element inside a drawable child of the canvas.
  2. The patches. Each is a <template for>. It carries new start and end instructions, so the range can be patched again.
  3. Send them. Only the Unsafe streaming methods apply patches; the sanitising ones drop processing instructions.
  4. Which tile changed, and which tile is new. A MutationObserver on the grid.
  5. Reorder with moveBefore(). Record where each tile is drawn, move the elements, and let the canvas travel from the old place to the new one.
  6. On paint. Upload the tiles in changedElements, then draw each tile at its place.
  7. The fragment shader. A rim and a scan line on a tile that just changed, a moving band on a tile that still holds its placeholder, and the shadow of a tile in flight.

How it works

Each tile is a drawable element with its own texture. The patch buttons write <template for> elements into the document with streamAppendHTMLUnsafe(), 14 characters at a time. The browser puts each template's content into the range of the same name. A MutationObserver records which tile changed and when; the paint event's changedElements says which textures to upload again. A shuffle records where each tile is drawn, reorders the elements, and the canvas draws each quad on a path from the old place to the tile's new layout box for 600 ms.

Live checks

They run on a separate small canvas and take the focus for a moment.

CheckResultDetail
A streamed <template for> replaces a range in a canvas childnot run
The sanitising stream leaves the range alonenot run
The patch raises paint, and changedElements names the patched elementnot run
A drawable element added by a patch is drawn at the next paintnot run
moveBefore() keeps focus and animation time; insertBefore() does notnot run

Findings