import { artefact } from "./library.js";
import { getSortedRootElements } from '../helper/document-root-elements.js';Scrawl-canvas breaks down the Display cycle into three parts: clear; compile; and show. These can be triggered either as a single, combined render operation, or separately as-and-when needed.
The order in which DOM stack and canvas elements are processed during the display cycle can be changed by setting that element’s controller’s order attribute to a higher or lower integer value; elements are processed (in batches) from lowest to highest order value
Each display cycle function is a normal Javascript function, invoked with no arguments and returning no status
Note that Scrawl-canvas supplies a convenience function - makeRender() - for automating the process of creating an animation object to handle the Display cycle
import { artefact } from "./library.js";
import { getSortedRootElements } from '../helper/document-root-elements.js';Shared constants
import { CLEAR } from '../helper/shared-vars.js';Local constants
const COMPILE = 'compile',
RENDER = 'render',
SHOW = 'show';Helper functions coordinate the actions required to complete a display cycle
const displayCycleHelper = function (items) {
if (items.length) return items;
return getSortedRootElements();
};
const displayCycleBatchProcess = function (rootWrappers, method) {
let i, iz, item;
for (i = 0, iz = rootWrappers.length; i < iz; i++) {
item = artefact[rootWrappers[i]];
if (item && item[method]) item[method]();
}
};Exported function (to modules and scrawl object).
export const clear = function (...items) {
const wrappers = displayCycleHelper(items);
displayCycleBatchProcess(wrappers, CLEAR);
};Exported function (to modules and scrawl object).
export const compile = function (...items) {
const wrappers = displayCycleHelper(items);
displayCycleBatchProcess(wrappers, COMPILE);
};Exported function (to modules and scrawl object).
export const show = function (...items) {
const wrappers = displayCycleHelper(items);
displayCycleBatchProcess(wrappers, SHOW);
};Exported function (to modules and scrawl object).
export const render = function (...items) {
const wrappers = displayCycleHelper(items);
displayCycleBatchProcess(wrappers, RENDER);
};