Platinum sponsors

muted NEW

Disables the value updates, the callbacks and the completion promise of a timer, while keeping its timing.

A muted timer runs like the others: it begins, loops and completes at the same times, so the timing of a timeline does not change when a child is muted, but it writes nothing and calls nothing.

Accepts

Boolean

Default

false

muted is set at creation and cannot change afterwards: recreate the timer to mute or unmute it.

muted code example

import { createTimer, utils } from 'animejs';

const [ $timeA ] = utils.$('.time-a');
const [ $timeB ] = utils.$('.time-b');

createTimer({
  duration: 2000,
  loop: true,
  onUpdate: self => $timeA.innerHTML = self.currentTime,
});

createTimer({
  duration: 2000,
  loop: true,
  muted: true,
  onUpdate: self => $timeB.innerHTML = self.currentTime, // Never called
});
<div class="large centered row">
  <div class="col">
    <pre class="large log row">
      <span class="label">muted: false</span>
      <span class="time-a value lcd">0</span>
    </pre>
  </div>
  <div class="col">
    <pre class="large log row">
      <span class="label">muted: true</span>
      <span class="time-b value lcd">0</span>
    </pre>
  </div>
</div>
Previous
Next