scrawl-canvas
Version:
Version 8.9.4 - 19 Nov 2022
1,128 lines (727 loc) • 51.8 kB
HTML
<!DOCTYPE html>
<html>
<head>
<title>RenderAnimation factory</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="../../docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="../core/animationloop.html">
./source/core/animationloop.js
</a>
<a class="source" href="../core/document.html">
./source/core/document.js
</a>
<a class="source" href="../core/events.html">
./source/core/events.js
</a>
<a class="source" href="../core/init.html">
./source/core/init.js
</a>
<a class="source" href="../core/library.html">
./source/core/library.js
</a>
<a class="source" href="../core/random-seed.html">
./source/core/random-seed.js
</a>
<a class="source" href="../core/snippets.html">
./source/core/snippets.js
</a>
<a class="source" href="../core/userInteraction.html">
./source/core/userInteraction.js
</a>
<a class="source" href="../core/utilities.html">
./source/core/utilities.js
</a>
<a class="source" href="action.html">
./source/factory/action.js
</a>
<a class="source" href="anchor.html">
./source/factory/anchor.js
</a>
<a class="source" href="animation.html">
./source/factory/animation.js
</a>
<a class="source" href="bezier.html">
./source/factory/bezier.js
</a>
<a class="source" href="block.html">
./source/factory/block.js
</a>
<a class="source" href="canvas.html">
./source/factory/canvas.js
</a>
<a class="source" href="cell.html">
./source/factory/cell.js
</a>
<a class="source" href="cog.html">
./source/factory/cog.js
</a>
<a class="source" href="color.html">
./source/factory/color.js
</a>
<a class="source" href="conicGradient.html">
./source/factory/conicGradient.js
</a>
<a class="source" href="coordinate.html">
./source/factory/coordinate.js
</a>
<a class="source" href="crescent.html">
./source/factory/crescent.js
</a>
<a class="source" href="element.html">
./source/factory/element.js
</a>
<a class="source" href="emitter.html">
./source/factory/emitter.js
</a>
<a class="source" href="filter.html">
./source/factory/filter.js
</a>
<a class="source" href="filterEngine-bluenoiseData.html">
./source/factory/filterEngine-bluenoiseData.js
</a>
<a class="source" href="filterEngine.html">
./source/factory/filterEngine.js
</a>
<a class="source" href="fontAttributes.html">
./source/factory/fontAttributes.js
</a>
<a class="source" href="gradient.html">
./source/factory/gradient.js
</a>
<a class="source" href="grid.html">
./source/factory/grid.js
</a>
<a class="source" href="group.html">
./source/factory/group.js
</a>
<a class="source" href="imageAsset.html">
./source/factory/imageAsset.js
</a>
<a class="source" href="line.html">
./source/factory/line.js
</a>
<a class="source" href="lineSpiral.html">
./source/factory/lineSpiral.js
</a>
<a class="source" href="loom.html">
./source/factory/loom.js
</a>
<a class="source" href="mesh.html">
./source/factory/mesh.js
</a>
<a class="source" href="net.html">
./source/factory/net.js
</a>
<a class="source" href="noiseAsset.html">
./source/factory/noiseAsset.js
</a>
<a class="source" href="oval.html">
./source/factory/oval.js
</a>
<a class="source" href="palette.html">
./source/factory/palette.js
</a>
<a class="source" href="particle.html">
./source/factory/particle.js
</a>
<a class="source" href="particleForce.html">
./source/factory/particleForce.js
</a>
<a class="source" href="particleHistory.html">
./source/factory/particleHistory.js
</a>
<a class="source" href="particleSpring.html">
./source/factory/particleSpring.js
</a>
<a class="source" href="particleWorld.html">
./source/factory/particleWorld.js
</a>
<a class="source" href="pattern.html">
./source/factory/pattern.js
</a>
<a class="source" href="phrase.html">
./source/factory/phrase.js
</a>
<a class="source" href="picture.html">
./source/factory/picture.js
</a>
<a class="source" href="polygon.html">
./source/factory/polygon.js
</a>
<a class="source" href="polyline.html">
./source/factory/polyline.js
</a>
<a class="source" href="quadratic.html">
./source/factory/quadratic.js
</a>
<a class="source" href="quaternion.html">
./source/factory/quaternion.js
</a>
<a class="source" href="radialGradient.html">
./source/factory/radialGradient.js
</a>
<a class="source" href="rawAsset.html">
./source/factory/rawAsset.js
</a>
<a class="source" href="rdAsset.html">
./source/factory/rdAsset.js
</a>
<a class="source" href="rectangle.html">
./source/factory/rectangle.js
</a>
<a class="source" href="renderAnimation.html">
./source/factory/renderAnimation.js
</a>
<a class="source" href="shape.html">
./source/factory/shape.js
</a>
<a class="source" href="spiral.html">
./source/factory/spiral.js
</a>
<a class="source" href="spriteAsset.html">
./source/factory/spriteAsset.js
</a>
<a class="source" href="stack.html">
./source/factory/stack.js
</a>
<a class="source" href="star.html">
./source/factory/star.js
</a>
<a class="source" href="state.html">
./source/factory/state.js
</a>
<a class="source" href="tetragon.html">
./source/factory/tetragon.js
</a>
<a class="source" href="ticker.html">
./source/factory/ticker.js
</a>
<a class="source" href="tracer.html">
./source/factory/tracer.js
</a>
<a class="source" href="tween.html">
./source/factory/tween.js
</a>
<a class="source" href="unstackedElement.html">
./source/factory/unstackedElement.js
</a>
<a class="source" href="vector.html">
./source/factory/vector.js
</a>
<a class="source" href="videoAsset.html">
./source/factory/videoAsset.js
</a>
<a class="source" href="wheel.html">
./source/factory/wheel.js
</a>
<a class="source" href="../mixin/anchor.html">
./source/mixin/anchor.js
</a>
<a class="source" href="../mixin/asset.html">
./source/mixin/asset.js
</a>
<a class="source" href="../mixin/assetAdvancedFunctionality.html">
./source/mixin/assetAdvancedFunctionality.js
</a>
<a class="source" href="../mixin/assetConsumer.html">
./source/mixin/assetConsumer.js
</a>
<a class="source" href="../mixin/base.html">
./source/mixin/base.js
</a>
<a class="source" href="../mixin/cascade.html">
./source/mixin/cascade.js
</a>
<a class="source" href="../mixin/delta.html">
./source/mixin/delta.js
</a>
<a class="source" href="../mixin/displayShape.html">
./source/mixin/displayShape.js
</a>
<a class="source" href="../mixin/dom.html">
./source/mixin/dom.js
</a>
<a class="source" href="../mixin/entity.html">
./source/mixin/entity.js
</a>
<a class="source" href="../mixin/filter.html">
./source/mixin/filter.js
</a>
<a class="source" href="../mixin/mimic.html">
./source/mixin/mimic.js
</a>
<a class="source" href="../mixin/path.html">
./source/mixin/path.js
</a>
<a class="source" href="../mixin/pattern.html">
./source/mixin/pattern.js
</a>
<a class="source" href="../mixin/pivot.html">
./source/mixin/pivot.js
</a>
<a class="source" href="../mixin/position.html">
./source/mixin/position.js
</a>
<a class="source" href="../mixin/shapeBasic.html">
./source/mixin/shapeBasic.js
</a>
<a class="source" href="../mixin/shapeCurve.html">
./source/mixin/shapeCurve.js
</a>
<a class="source" href="../mixin/shapePathCalculation.html">
./source/mixin/shapePathCalculation.js
</a>
<a class="source" href="../mixin/styles.html">
./source/mixin/styles.js
</a>
<a class="source" href="../mixin/tween.html">
./source/mixin/tween.js
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="section-1">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-1">§</a>
</div>
<h1 id="renderanimation-factory">RenderAnimation factory</h1>
<p>RenderAnimation objects are animations that aim to simplify coding up Display cycles. They remove the need to worry about Promises, while at the same time exposing a suite of Display cycle hooks - attributes which can accept a function to be run at various points during a Display cycle </p>
<ul>
<li><code>commence</code> - triggers at the start of the Display cycle, before the <code>clear</code> cascade begins.</li>
<li><code>afterClear</code> - triggers when the <code>clear</code> cascade completes, before the <code>compile</code> cascade begins.</li>
<li><code>afterCompile</code> - triggers when the <code>compile</code> cascade completes, before the <code>show</code> cascade begins.</li>
<li><code>afterShow</code> - triggers at the end of the Display cycle, after the <code>show</code> cascade completes.</li>
<li><code>afterCreated</code> - triggers once, after the first Display cycle completes.</li>
<li><code>error</code> - triggers when the Display cycle throws an error.</li>
</ul>
<p>Note that all the above functions should be normal, synchronous functions. The Animation object will run them within its main, asynchronous (Promise-based) function.</p>
<p>The RenderAnimation object also supports the Animation object’s <strong>animation hook functions</strong>:</p>
<ul>
<li><code>onRun</code> - triggers each time the RenderAnimation object’s <code>run</code> function is invoked</li>
<li><code>onHalt</code> - triggers each time the RenderAnimation object’s <code>halt</code> function is invoked</li>
<li><code>onKill</code> - triggers each time the RenderAnimation object’s <code>kill</code> function is invoked</li>
</ul>
<p>In addition to RenderAnimation attributes, the factory’s argument object can include two additional flags, which influence the make functionality:</p>
<ul>
<li><strong>delay</strong> - when set to true, will prevent the animation running immediately; to start the animation, invoke its <strong>run</strong> function</li>
<li><strong>observe</strong> - when set to true, will add an IntersectionObserver to the target’s DOM element, which in turn assigns a disconnect function to the <code>RenderAnimation.observe</code> attribute</li>
</ul>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-2">§</a>
</div>
<h4 id="demos">Demos:</h4>
<ul>
<li>Most Demos use RenderAnimation for managing their Display cycle</li>
</ul>
</div>
</li>
<li id="section-3">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-3">§</a>
</div>
<h4 id="imports">Imports</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">import</span> { animation, artefact, constructors } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/library.js'</span>;
<span class="hljs-keyword">import</span> { clear, compile, show } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/document.js'</span>;
<span class="hljs-keyword">import</span> { makeAnimationObserver } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/events.js'</span>;
<span class="hljs-keyword">import</span> { mergeOver, pushUnique, removeItem, xt, λ<span class="hljs-literal">null</span>, λ<span class="hljs-variable language_">this</span>, Ωempty, isa_boolean } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/utilities.js'</span>;
<span class="hljs-keyword">import</span> { animate, resortAnimations } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/animationloop.js'</span>;
<span class="hljs-keyword">import</span> { forceUpdate } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/userInteraction.js'</span>;
<span class="hljs-keyword">import</span> baseMix <span class="hljs-keyword">from</span> <span class="hljs-string">'../mixin/base.js'</span>;</pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-4">§</a>
</div>
<h4 id="renderanimation-constructor">RenderAnimation constructor</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">const</span> <span class="hljs-title class_">RenderAnimation</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">items = Ωempty</span>) {
<span class="hljs-keyword">let</span> target;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">noTarget</span> = (items.<span class="hljs-property">noTarget</span> != <span class="hljs-literal">null</span>) ? items.<span class="hljs-property">noTarget</span> : <span class="hljs-literal">false</span>;</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-5">§</a>
</div>
<p>Handle cases where no target has been defined - the animation will affect all stacks and canvases</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (!items.<span class="hljs-property">target</span> && !items.<span class="hljs-property">noTarget</span>) target = {
<span class="hljs-attr">clear</span>: clear,
<span class="hljs-attr">compile</span>: compile,
<span class="hljs-attr">show</span>: show,
<span class="hljs-attr">checkAccessibilityValues</span>: λ<span class="hljs-literal">null</span>,
};</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-6">§</a>
</div>
<p>Handle cases where we have multiple targets - each needs its own render animation</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-title class_">Array</span>.<span class="hljs-title function_">isArray</span>(items.<span class="hljs-property">target</span>)) {
<span class="hljs-keyword">let</span> multiReturn = []
items.<span class="hljs-property">target</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">tempTarget</span> =></span> {
<span class="hljs-keyword">let</span> tempItems = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">assign</span>({}, items);
tempItems.<span class="hljs-property">name</span> = <span class="hljs-string">`<span class="hljs-subst">${tempItems.name}</span>_<span class="hljs-subst">${tempTarget.name}</span>`</span>;
tempItems.<span class="hljs-property">target</span> = tempTarget;
multiReturn.<span class="hljs-title function_">push</span>(<span class="hljs-keyword">new</span> <span class="hljs-title class_">RenderAnimation</span>(tempItems));
});
<span class="hljs-keyword">return</span> multiReturn;
}</pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-7">§</a>
</div>
<p>Default case where we have a single target</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> target = (items.<span class="hljs-property">target</span> && items.<span class="hljs-property">target</span>.<span class="hljs-property">substring</span>) ? artefact[items.<span class="hljs-property">target</span>] : items.<span class="hljs-property">target</span>;</pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-8">§</a>
</div>
<p>Without a target, we can progress no further
if (!target || !target.clear || !target.compile || !target.show) return false;</p>
</div>
</li>
<li id="section-9">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-9">§</a>
</div>
<p>All should be good - proceed with animation creation</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">makeName</span>(items.<span class="hljs-property">name</span>);</pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-10">§</a>
</div>
<p>These attributes are the same as for the Animation object</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-variable language_">this</span>.<span class="hljs-property">order</span> = (<span class="hljs-title function_">xt</span>(items.<span class="hljs-property">order</span>)) ? items.<span class="hljs-property">order</span> : <span class="hljs-variable language_">this</span>.<span class="hljs-property">defs</span>.<span class="hljs-property">order</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">onRun</span> = items.<span class="hljs-property">onRun</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">onHalt</span> = items.<span class="hljs-property">onHalt</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">onKill</span> = items.<span class="hljs-property">onKill</span> || λ<span class="hljs-literal">null</span>;</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-11">§</a>
</div>
<p>These attributes are specific to RenderAnimation</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span> = target;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">commence</span> = items.<span class="hljs-property">commence</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">afterClear</span> = items.<span class="hljs-property">afterClear</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">afterCompile</span> = items.<span class="hljs-property">afterCompile</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">afterShow</span> = items.<span class="hljs-property">afterShow</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">afterCreated</span> = items.<span class="hljs-property">afterCreated</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">error</span> = items.<span class="hljs-property">error</span> || λ<span class="hljs-literal">null</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">readyToInitialize</span> = <span class="hljs-literal">true</span>;</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-12">§</a>
</div>
<h5 id="the-display-cycle-promise-chain">The Display cycle Promise chain</h5>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-variable language_">this</span>.<span class="hljs-property">fn</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">noTarget</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">commence</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterClear</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterCompile</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterShow</span>();
<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">readyToInitialize</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterCreated</span>(<span class="hljs-variable language_">this</span>);
<span class="hljs-variable language_">this</span>.<span class="hljs-property">readyToInitialize</span> = <span class="hljs-literal">false</span>;
}
}
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">isRunning</span>()) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">commence</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>.<span class="hljs-title function_">clear</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterClear</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>.<span class="hljs-title function_">compile</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterCompile</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>.<span class="hljs-title function_">show</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterShow</span>();
<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">readyToInitialize</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>.<span class="hljs-title function_">checkAccessibilityValues</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">afterCreated</span>(<span class="hljs-variable language_">this</span>);
<span class="hljs-variable language_">this</span>.<span class="hljs-property">readyToInitialize</span> = <span class="hljs-literal">false</span>;
}
}
}</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-13">§</a>
</div>
<p>Register in Scrawl-canvas library</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">register</span>();</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-14">§</a>
</div>
<p>The <code>observer</code> attribute</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">const</span> obs = items.<span class="hljs-property">observer</span> || <span class="hljs-literal">false</span>;
<span class="hljs-keyword">if</span> (obs) {
<span class="hljs-keyword">if</span> (<span class="hljs-title function_">isa_boolean</span>(obs)) <span class="hljs-variable language_">this</span>.<span class="hljs-property">observer</span> = <span class="hljs-title function_">makeAnimationObserver</span>(<span class="hljs-variable language_">this</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>);
<span class="hljs-keyword">else</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">observer</span> = <span class="hljs-title function_">makeAnimationObserver</span>(<span class="hljs-variable language_">this</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>, obs);
}</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-15">§</a>
</div>
<p>Start the animation immediately, unless flagged otherwise</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span>(!items.<span class="hljs-property">delay</span>) <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">run</span>();
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-16">§</a>
</div>
<h4 id="renderanimation-prototype">RenderAnimation prototype</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">let</span> P = <span class="hljs-title class_">RenderAnimation</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span> = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-title class_">Object</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>);
P.<span class="hljs-property">type</span> = <span class="hljs-string">'RenderAnimation'</span>;
P.<span class="hljs-property">lib</span> = <span class="hljs-string">'animation'</span>;
P.<span class="hljs-property">isArtefact</span> = <span class="hljs-literal">false</span>;
P.<span class="hljs-property">isAsset</span> = <span class="hljs-literal">false</span>;</pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-17">§</a>
</div>
<h4 id="mixins">Mixins</h4>
</div>
<div class="content"><div class='highlight'><pre>P = <span class="hljs-title function_">baseMix</span>(P);</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-18">§</a>
</div>
<h4 id="renderanimation-attributes">RenderAnimation attributes</h4>
<ul>
<li>Attributes defined in the <a href="../mixin/base.html">base mixin</a>: <strong>name</strong>.</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">let</span> defaultAttributes = {</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-19">§</a>
</div>
<p><strong>order</strong> - positive integer Number. Determines the order in which each animation object will be actioned during the Display cycle. Higher order animations will be processed after lower order animations.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">order</span>: <span class="hljs-number">1</span>,</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-20">§</a>
</div>
<p><strong>onRun</strong>, <strong>onHalt</strong>, <strong>onKill</strong></p>
<p>The <a href="./animation.html">Animation object</a> supports the following <em><strong>animation hook functions</strong></em>:</p>
<ul>
<li><code>onRun</code> - triggers each time the animation object’s <code>run</code> function is invoked.</li>
<li><code>onHalt</code> - triggers each time the animation object’s <code>halt</code> function is invoked.</li>
<li><code>onKill</code> - triggers each time the animation object’s <code>kill</code> function is invoked.</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">onRun</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onHalt</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onKill</span>: <span class="hljs-literal">null</span>,</pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-21">§</a>
</div>
<p><strong>commence</strong>, <strong>afterClear</strong>, <strong>afterCompile</strong>, <strong>afterShow</strong>, <strong>afterCreated</strong>, <strong>error</strong></p>
<p>RenderAnimation objects support the following <em><strong>Display cycle hook functions</strong></em>:</p>
<ul>
<li><code>commence</code> - triggers at the start of the Display cycle, before the <code>clear</code> cascade begins.</li>
<li><code>afterClear</code> - triggers when the <code>clear</code> cascade completes, before the <code>compile</code> cascade begins.</li>
<li><code>afterCompile</code> - triggers when the <code>compile</code> cascade completes, before the <code>show</code> cascade begins.</li>
<li><code>afterShow</code> - triggers at the end of the Display cycle, after the <code>show</code> cascade completes.</li>
<li><code>afterCreated</code> - triggers once, after the first Display cycle completes.</li>
<li><code>error</code> - triggers when the Display cycle throws an error.</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">commence</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">afterClear</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">afterCompile</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">afterShow</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">afterCreated</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">error</span>: <span class="hljs-literal">null</span>,</pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-22">§</a>
</div>
<p><strong>target</strong> - handle to the <a href="./stack.html">Stack</a> or <a href="./cell.html">Cell</a> wrapper object; each can have its own Display cycle animation.</p>
<ul>
<li>Can be supplied in the argument object as either a name-String for the target object, or the target object itself</li>
<li>Will also accept an Array of Strings and/or obvjects</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">target</span>: <span class="hljs-literal">null</span>,
};
P.<span class="hljs-property">defs</span> = <span class="hljs-title function_">mergeOver</span>(P.<span class="hljs-property">defs</span>, defaultAttributes);</pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-23">§</a>
</div>
<h4 id="packet-management">Packet management</h4>
<p>Animations do not take part in the packet or clone systems; they can, however, be used for importing and actioning packets as they retain those base functions</p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">stringifyFunction</span> = λ<span class="hljs-literal">null</span>;
P.<span class="hljs-property">processPacketOut</span> = λ<span class="hljs-literal">null</span>;
P.<span class="hljs-property">finalizePacketOut</span> = λ<span class="hljs-literal">null</span>;
P.<span class="hljs-property">saveAsPacket</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-keyword">return</span> <span class="hljs-string">`[<span class="hljs-subst">${<span class="hljs-variable language_">this</span>.name}</span>, <span class="hljs-subst">${<span class="hljs-variable language_">this</span>.type}</span>, <span class="hljs-subst">${<span class="hljs-variable language_">this</span>.lib}</span>, {}]`</span>
};</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-24">§</a>
</div>
<h4 id="clone-management">Clone management</h4>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">clone</span> = λ<span class="hljs-variable language_">this</span>;</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-25">§</a>
</div>
<h4 id="kill-management">Kill management</h4>
<p>Stops the animation if it is already running, and removes it from the Scrawl-canvas library</p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">kill</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">onKill</span>();
<span class="hljs-title function_">removeItem</span>(animate, <span class="hljs-variable language_">this</span>.<span class="hljs-property">name</span>);
<span class="hljs-title function_">resortAnimations</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">deregister</span>();
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
};</pre></div></div>
</li>
<li id="section-26">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-26">§</a>
</div>
<h4 id="get-set-deltaset">Get, Set, deltaSet</h4>
<p>No additional get/set functionality required</p>
</div>
</li>
<li id="section-27">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-27">§</a>
</div>
<h4 id="prototype-functions">Prototype functions</h4>
</div>
</li>
<li id="section-28">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-28">§</a>
</div>
<p><code>run</code> - start the animation, if it is not already running</p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">run</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">onRun</span>();
<span class="hljs-title function_">pushUnique</span>(animate, <span class="hljs-variable language_">this</span>.<span class="hljs-property">name</span>);
<span class="hljs-title function_">resortAnimations</span>();
<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>) <span class="hljs-variable language_">this</span>.<span class="hljs-property">target</span>.<span class="hljs-title function_">checkAccessibilityValues</span>();
<span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =></span> <span class="hljs-title function_">forceUpdate</span>(), <span class="hljs-number">20</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-29">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-29">§</a>
</div>
<p><code>isRunning</code> - returns Boolean true if animation is running; false otherwise</p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">isRunning</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-keyword">return</span> (animate.<span class="hljs-title function_">indexOf</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">name</span>) >= <span class="hljs-number">0</span>) ? <span class="hljs-literal">true</span> : <span class="hljs-literal">false</span>;
};</pre></div></div>
</li>
<li id="section-30">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-30">§</a>
</div>
<p><code>halt</code> - stop the animation, if it is already running</p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">halt</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">onHalt</span>();
<span class="hljs-title function_">removeItem</span>(animate, <span class="hljs-variable language_">this</span>.<span class="hljs-property">name</span>);
<span class="hljs-title function_">resortAnimations</span>();
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-31">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-31">§</a>
</div>
<h4 id="factory">Factory</h4>
<pre><code><span class="hljs-keyword">let</span> report = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-keyword">let</span> testTicker = <span class="hljs-title class_">Date</span>.<span class="hljs-title function_">now</span>(),
testTime, testNow,
testMessage = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">querySelector</span>(<span class="hljs-string">'#reportmessage'</span>);
<span class="hljs-keyword">return</span> <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
testNow = <span class="hljs-title class_">Date</span>.<span class="hljs-title function_">now</span>();
testTime = testNow - testTicker;
testTicker = testNow;
testMessage.<span class="hljs-property">textContent</span> = <span class="hljs-string">`Screen