Usage

With the layout.record() & layout.animate() combo

Create and record() the initial state of a layout:

const layout = createLayout(rootEl);

layout.record();

Change the layout state (update CSS, remove or add elements, etc.):

rootEl.classList.toggle('row');

animate() from the old state to the new one automatically:

layout.animate();

With layout.update()

Or even simpler, by updating the DOM state inside the update() callback in one single call:

const layout = createLayout(rootEl);

layout.update(() => rootEl.classList.toggle('row'));