scrawl-canvas
Version:
Version 8.9.4 - 19 Nov 2022
1,128 lines (734 loc) • 108 kB
HTML
<!DOCTYPE html>
<html>
<head>
<title>Ticker 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="ticker-factory">Ticker factory</h1>
<p>Ticker objects represent a timeline against which <a href="./tween.html">Tween</a> and <a href="./action.html">Action</a> objects will run.</p>
<ul>
<li><em><strong>A Ticker is an animation</strong></em> (but not a Scrawl-canvas <a href="./animation.html">Animation</a>) object; it defines a <code>fn</code> function internally which will check through all Tween and Action objects subscribing to it and, where appropriate, trigger their <code>update</code> functions.</li>
<li>This module defines and launches a <code>coreTickersAnimation</code> Animation object; all Ticker objects get added to this object when their <code>run</code> or <code>resume</code> functions are triggered.</li>
<li>The <code>coreTickersAnimation</code> object runs in the Scrawl-canvas <code>animationLoop</code> which is tied to the browser/device’s requestAnimationFrame (RAF) functionality. </li>
<li><code>coreTickersAnimation</code> runs before other Animation objects, thus <em><strong>Tween/Action updates happen before any Display cycle functionality</strong></em>.</li>
<li>Unlike Animation objects, <em><strong>Ticker objects do not run automatically</strong></em> as soon as they have been created.</li>
<li>To trigger a Ticker object, invoke its <code>run</code> or <code>resume</code> functions.</li>
</ul>
<p>Ticker objects have an <em><strong>effective duration</strong></em> - a set number of milliseconds for which they will run.</p>
<ul>
<li>We can set this value directly, using the <code>duration</code> attribute.</li>
<li>We can also ask the Ticker to calculate its own effective duration, taking into accout the start times and duration of its currently subscribed Tweens and Actions</li>
<li>By default a Ticker will run once, then terminate (remove itself from the <code>coreTickersAnimation</code> function). This counts as 1 cycle.</li>
<li>We can get the Ticker to run multiple times before terminating, by setting its <code>cycles</code> attribute to a positive integer Number value.</li>
<li>Setting the <code>cycles</code> attribute to <code>0</code> causes the Ticker to run continuously once started, until told to stop.</li>
<li>Note that Tickers always run forwards, never backwards. Tweens and Actions can be reversed by setting the appropriate flags on them.</li>
</ul>
<p>Tickers (unlike Animations) take part in Scrawl-canvas packet functionality; they can be saved, restored and cloned.</p>
<p>Tickers can be controlled through a set of trigger functions: <strong>run, halt, reverse, resume, seekTo, seekFor, complete, reset</strong>.</p>
<ul>
<li>We can add <em><strong>Ticker hook functions</strong></em> to each of these trigger functions.</li>
</ul>
<p>A Ticker can be made to dispatch a <a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent">DOM Custom Event</a> at regular intervals as it runs, by setting its <code>eventChoke</code> attribute to a Number value (representing milliseconds) greater than <code>0</code>.</p>
<ul>
<li>The Custom Event is named <code>tickerupdate</code>.</li>
<li>Its <code>detail</code> object includes the following attributes: <strong>name</strong> (Ticker name-String); <strong>type</strong> (<code>Ticker</code>); <strong>tick</strong> (milliseconds since Ticker started running); <strong>reverseTick</strong> (milliseconds remaining until Ticker completes its current cycle).</li>
<li>The Event bubbles, and is cancelable.</li>
</ul>
<p>Tickers are very closely associated with Tweens.</p>
<ul>
<li>Each Ticker can have more than one Tween (and 0 or more Actions) subscribed to it.</li>
<li>Tweens and Actions can be told to subscribe to a Ticker when they are created; they can change their Ticker subscription at any time.</li>
<li><em><strong>A Tween can make its own Ticker when it is created.</strong></em></li>
</ul>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-2">§</a>
</div>
<p>TODO: basic packet and kill functionality tested in Demo DOM-004, but there’s a lot of Ticker/Tween/Action functionality that needs to be explored and tested further:</p>
<ul>
<li>If we kill a Ticker but leave associated Tweens untouched, will running those Tweens crash the script?</li>
<li>Can we successfully clone a Tween whose Ticker has been killed?</li>
<li>A Ticker can have more than one subscribed Tween/Action; can (should?) Tweens/Actions be able to subscribe to more than one Ticker? <em>Initial thoughts: no - if such functionality required, clone the Tween/Action</em></li>
<li>Can Tickers be nested? How could we use nested Tickers? <em>Initial thoughts: yes to nesting, possibly use an Action on one ticker to run/halt a second Ticker; one use case may be to break up a complex animation into smaller, more discrete parts? But this all begs the question: if we halt a nested Ticker (via user interaction), how would we cascade that through to parent/sibling Tickers?</em></li>
<li>Possible additional demo - tie a more complex Ticker/Tween/Action sequence to a graphical timeline - see blog post <a href="https://blog.rikworks.co.uk/2018/05/26/Adding-some-canvas-love-to-Hexo/">Adding some canvas love to Hexo</a>.</li>
<li>Would be a Big Win if we can tether Ticker/Tween/Actions to progress while a video plays - opens up the world of <em><strong>interactive video</strong></em>.</li>
</ul>
</div>
</li>
<li id="section-3">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-3">§</a>
</div>
<h4 id="demos">Demos:</h4>
<ul>
<li>All Tween and Action-related Demos necessarily include Tickers</li>
<li><a href="../../demo/canvas-005.html">Canvas-005</a> - Cell-locked, and Entity-locked, gradients; animating gradients by delta, and by tween</li>
<li><a href="../../demo/canvas-006.html">Canvas-006</a> - Canvas tween stress test</li>
<li><a href="../../demo/dom-004.html">DOM-004</a> - Limitless rockets (clone and destroy elements, tweens, tickers)</li>
<li><a href="../../demo/dom-005.html">DOM-005</a> - DOM tween stress test</li>
<li><a href="../../demo/dom-006.html">DOM-006</a> - Tween actions on a DOM element; tracking tween and ticker activity (analytics)</li>
<li><a href="../../demo/snippets-001.html">Snippets-001</a> - Scrawl-canvas DOM element snippets</li>
</ul>
</div>
</li>
<li id="section-4">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-4">§</a>
</div>
<h4 id="imports">Imports</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">import</span> { constructors, animationtickers, tween } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/library.js'</span>;
<span class="hljs-keyword">import</span> { mergeOver, pushUnique, removeItem, xt, xtGet, isa_obj, convertTime, Ωempty } <span class="hljs-keyword">from</span> <span class="hljs-string">'../core/utilities.js'</span>;
<span class="hljs-keyword">import</span> { makeAnimation } <span class="hljs-keyword">from</span> <span class="hljs-string">'./animation.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-5">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-5">§</a>
</div>
<h4 id="ticker-constructor">Ticker constructor</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">const</span> <span class="hljs-title class_">Ticker</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">items = Ωempty</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">makeName</span>(items.<span class="hljs-property">name</span>);
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">register</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span> = [];
<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscriberObjects</span> = [];
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">set</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">defs</span>);
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">set</span>(items);
<span class="hljs-variable language_">this</span>.<span class="hljs-property">cycleCount</span> = <span class="hljs-number">0</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">active</span> = <span class="hljs-literal">false</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">effectiveDuration</span> = <span class="hljs-number">0</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">startTime</span> = <span class="hljs-number">0</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">currentTime</span> = <span class="hljs-number">0</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">tick</span> = <span class="hljs-number">0</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">lastEvent</span> = <span class="hljs-number">0</span>;
<span class="hljs-keyword">if</span> (items.<span class="hljs-property">subscribers</span>) <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">subscribe</span>(items.<span class="hljs-property">subscribers</span>);
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setEffectiveDuration</span>();
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-6">§</a>
</div>
<h4 id="ticker-prototype">Ticker prototype</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">let</span> P = <span class="hljs-title class_">Ticker</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">'Ticker'</span>;
P.<span class="hljs-property">lib</span> = <span class="hljs-string">'animationtickers'</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-7">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-7">§</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-8">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-8">§</a>
</div>
<h4 id="ticker-attributes">Ticker 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-9">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-9">§</a>
</div>
<p><strong>order</strong> - positive integer Number - determines the order in which each Ticker animation object will be actioned before the Display cycle starts. </p>
<ul>
<li>Higher order Tickers will be processed after lower order Tickers. </li>
<li>Tickers with the same <code>order</code> value will be processed in the order in which they were defined in code.</li>
</ul>
</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-10">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-10">§</a>
</div>
<p><strong>duration</strong> - can accept a variety of values:</p>
<ul>
<li>Number, representing milliseconds.</li>
<li>String time value, for example <code>'500ms', '0.5s'</code>.</li>
<li>(% String values cannot be used with Ticker objects - they have nothing to measure such a relative value against).</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">duration</span>: <span class="hljs-number">0</span>,</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-11">§</a>
</div>
<p><strong>subscribers</strong> - Array of Tween and Action name-Strings. Use <code>subscribe</code> and <code>unsubscribe</code> functions rather than the <code>set</code> function to add/remove Tweens and/or Actions to/from the Ticker</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">subscribers</span>: <span class="hljs-literal">null</span>,</pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-12">§</a>
</div>
<p><strong>killOnComplete</strong> - Boolean flag. When set, the Ticker will kill both itself and all Tweens and Actions associated with it at the end of its run</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">killOnComplete</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><strong>cycles</strong> - positive integer Number representing the number of cycles the Ticker will run before it completes. </p>
<ul>
<li>A value of <code>0</code> indicates that the Ticker should repeat itself forever, until its <code>halt</code>, <code>seekTo</code>, <code>seekFor</code>, <code>complete</code> or <code>reset</code> functions are triggered.</li>
<li>Note that Tween and Action animation direction is determined by those objects (via their <code>reverseOnCycleEnd</code> and <code>reversed</code> flags). Tickers always repeat in a forwards direction - they loop back to their start; they never reverse time.</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">cycles</span>: <span class="hljs-number">1</span>,</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-14">§</a>
</div>
<p><strong>eventChoke</strong> - positive Number representing the time to elapse before the Ticker creates and emits another event. A value of <code>0</code> stops the Ticker emitting events as it runs.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-attr">eventChoke</span>: <span class="hljs-number">0</span>,</pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-15">§</a>
</div>
<p>The Ticker object supports some <strong>hook functions</strong>:</p>
<ul>
<li><strong>onRun</strong> - triggers each time the Ticker’s <code>run</code> function is invoked</li>
<li><strong>onHalt</strong> - triggers each time the Ticker’s <code>halt</code> function is invoked</li>
<li><strong>onReverse</strong> - triggers each time the Ticker’s <code>reverse</code> function is invoked</li>
<li><strong>onResume</strong> - triggers each time the Ticker’s <code>resume</code> function is invoked</li>
<li><strong>onSeekTo</strong> - triggers each time the Ticker’s <code>seekTo</code> function is invoked</li>
<li><strong>onSeekFor</strong> - triggers each time the Ticker’s <code>seekFor</code> function is invoked</li>
<li><strong>onComplete</strong> - triggers each time the Ticker’s <code>complete</code> function is invoked</li>
<li><strong>onReset</strong> - triggers each time the Ticker’s <code>reset</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">onReverse</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onResume</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onSeekTo</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onSeekFor</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onComplete</span>: <span class="hljs-literal">null</span>,
<span class="hljs-attr">onReset</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-16">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-16">§</a>
</div>
<h4 id="packet-management">Packet management</h4>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">packetExclusions</span> = <span class="hljs-title function_">pushUnique</span>(P.<span class="hljs-property">packetExclusions</span>, [<span class="hljs-string">'subscribers'</span>]);
P.<span class="hljs-property">packetFunctions</span> = <span class="hljs-title function_">pushUnique</span>(P.<span class="hljs-property">packetFunctions</span>, [<span class="hljs-string">'onRun'</span>, <span class="hljs-string">'onHalt'</span>, <span class="hljs-string">'onReverse'</span>, <span class="hljs-string">'onResume'</span>, <span class="hljs-string">'onSeekTo'</span>, <span class="hljs-string">'onSeekFor'</span>, <span class="hljs-string">'onComplete'</span>, <span class="hljs-string">'onReset'</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="clone-management">Clone management</h4>
<p>No additional clone functionality required.</p>
</div>
</li>
<li id="section-18">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-18">§</a>
</div>
<h4 id="kill-management">Kill management</h4>
<p><code>kill</code> - remove Ticker from Scrawl-canvas system.</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-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">active</span>) <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">halt</span>();
<span class="hljs-title function_">removeItem</span>(tickerAnimations, <span class="hljs-variable language_">this</span>.<span class="hljs-property">name</span>);
tickerAnimationsFlag = <span class="hljs-literal">true</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-19">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-19">§</a>
</div>
<p><code>killTweens</code> - remove a Ticker’s subscribed Tweens from Scrawl-canvas system.</p>
<ul>
<li>If the function is invoked with a truthy argument, the Ticker will also be removed from the system.</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">killTweens</span> = <span class="hljs-keyword">function</span>(<span class="hljs-params">autokill = <span class="hljs-literal">false</span></span>) {
<span class="hljs-keyword">let</span> i, iz, sub;
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>, iz = <span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span>.<span class="hljs-property">length</span>; i < iz; i++) {
sub = tween[<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span>[i]];
sub.<span class="hljs-title function_">completeAction</span>();
sub.<span class="hljs-title function_">kill</span>();
}
<span class="hljs-keyword">if</span> (autokill) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">kill</span>();
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-20">§</a>
</div>
<h4 id="get-set-deltaset">Get, Set, deltaSet</h4>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">let</span> G = P.<span class="hljs-property">getters</span>,
S = P.<span class="hljs-property">setters</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>subscribers</strong> - see also the <code>subscribe</code> and <code>unsubscribe</code> functions below</p>
<ul>
<li>getter returns a copy of the <code>subscribers</code> Array, containing Tween and Action object name-Strings.</li>
<li>setter accepts a Tween or Action name-String, or an Array of such Strings. Will replace the existing <code>subscribers</code> Array with this new data.</li>
</ul>
</div>
<div class="content"><div class='highlight'><pre>G.<span class="hljs-property">subscribers</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) {
<span class="hljs-keyword">return</span> [].<span class="hljs-title function_">concat</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span>);
};
S.<span class="hljs-property">subscribers</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span> = [];
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">subscribe</span>(item);
};</pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-22">§</a>
</div>
<p><strong>order</strong></p>
</div>
<div class="content"><div class='highlight'><pre>S.<span class="hljs-property">order</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-property">order</span> = item;
<span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">active</span>) tickerAnimationsFlag = <span class="hljs-literal">true</span>;
};</pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-23">§</a>
</div>
<p><strong>cycles</strong></p>
</div>
<div class="content"><div class='highlight'><pre>S.<span class="hljs-property">cycles</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-property">cycles</span> = item;
<span class="hljs-keyword">if</span> (!<span class="hljs-variable language_">this</span>.<span class="hljs-property">cycles</span>) <span class="hljs-variable language_">this</span>.<span class="hljs-property">cycleCount</span> = <span class="hljs-number">0</span>;
};</pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-24">§</a>
</div>
<p><strong>duration</strong> - changes to the <code>duration</code> (and as a consequence <code>effectiveDuration</code>) attributes will be cascaded down to subscribed Tweens and Actions immediately.</p>
</div>
<div class="content"><div class='highlight'><pre>S.<span class="hljs-property">duration</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">item</span>) {
<span class="hljs-keyword">let</span> i, iz, target,
subscribers = <span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span>;
<span class="hljs-variable language_">this</span>.<span class="hljs-property">duration</span> = item;
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">setEffectiveDuration</span>();
<span class="hljs-keyword">if</span>(<span class="hljs-title function_">xt</span>(subscribers)){
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>, iz = subscribers.<span class="hljs-property">length</span>; i < iz; i++) {
target = tween[subscribers[i]];
<span class="hljs-keyword">if</span> (target) {
target.<span class="hljs-title function_">calculateEffectiveTime</span>();
<span class="hljs-keyword">if</span> (target.<span class="hljs-property">type</span> === <span class="hljs-string">'Tween'</span>) target.<span class="hljs-title function_">calculateEffectiveDuration</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="subscription-management">Subscription management</h4>
</div>
</li>
<li id="section-26">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-26">§</a>
</div>
<p><code>subscribe</code> - accepts a Tween or Action name-String, or an Array of such Strings. </p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">subscribe</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">items</span>) {
<span class="hljs-keyword">let</span> myItems = [].<span class="hljs-title function_">concat</span>(items),
i, iz, item, name;
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>, iz = myItems.<span class="hljs-property">length</span>; i < iz; i++) {
item = myItems[i];
<span class="hljs-keyword">if</span>(item != <span class="hljs-literal">null</span>){
<span class="hljs-keyword">if</span> (item.<span class="hljs-property">substring</span>) name = item;
<span class="hljs-keyword">else</span> name = (<span class="hljs-title function_">isa_obj</span>(item) && item.<span class="hljs-property">name</span>) ? item.<span class="hljs-property">name</span> : <span class="hljs-literal">false</span>;
<span class="hljs-keyword">if</span> (name) <span class="hljs-title function_">pushUnique</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span>, name);
}
}
<span class="hljs-keyword">if</span> (myItems.<span class="hljs-property">length</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">sortSubscribers</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">recalculateEffectiveDuration</span>();
}
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-27">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-27">§</a>
</div>
<p><code>unsubscribe</code> - accepts a Tween or Action name-String, or an Array of such Strings.</p>
</div>
<div class="content"><div class='highlight'><pre>P.<span class="hljs-property">unsubscribe</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">items</span>) {
<span class="hljs-keyword">var</span> myItems = [].<span class="hljs-title function_">concat</span>(items),
i, iz, item, name;
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>, iz = myItems.<span class="hljs-property">length</span>; i < iz; i++) {
item = items[i];
<span class="hljs-keyword">if</span> (item.<span class="hljs-property">substring</span>) name = item;
<span class="hljs-keyword">else</span> name = (<span class="hljs-title function_">isa_obj</span>(item) && item.<span class="hljs-property">name</span>) ? item.<span class="hljs-property">name</span> : <span class="hljs-literal">false</span>;
<span class="hljs-keyword">if</span> (name) <span class="hljs-title function_">removeItem</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">subscribers</span>, name);
}
<span class="hljs-keyword">if</span> (myItems.<span class="hljs-property">length</span>) {
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">sortSubscribers</span>();
<span class="hljs-variable language_">this</span>.<span class="hljs-title function_">recalculateEffectiveDuration</span>();
}
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
};</pre></div></div>
</li>
<li id="section-28">
<div class="annotation">
<div class="sswrap ">
<a class="ss" href="#section-28">&#x