cancel()
Pauses the timer, removes it from the engine's main loop, and frees up memory.
Returns
The timer itself
Can be chained with other timer methods.
cancel() code example
import { createTimer, utils } from 'animejs';
const [ $playButton ] = utils.$('.play');
const [ $cancelButton ] = utils.$('.cancel');
const [ $time ] = utils.$('.time');
const timer = createTimer({
onUpdate: self => $time.innerHTML = self.currentTime
});
const playTimer = () => timer.play();
const cancelTimer = () => timer.cancel();
$playButton.addEventListener('click', playTimer);
$cancelButton.addEventListener('click', cancelTimer);
<div class="large centered row">
<div class="half col">
<pre class="large log row">
<span class="label">current time</span>
<span class="time value lcd">0</span>
</pre>
</div>
</div>
<div class="medium row">
<fieldset class="controls">
<button class="button play">Play</button>
<button class="button cancel">Cancel</button>
</fieldset>
</div>