Core Module

Timer

The Timer module provides precise timing control and is the foundation of all animation playback in SZZ Labs.

createTimer()

Create a timer that ticks on every frame or at a specified interval.

import { createTimer } from 'animejs';

const timer = createTimer({
  duration: 2000,
  loop: true,
  onUpdate(self) {
    console.log(self.currentTime);
  },
  onComplete() {
    console.log('Done!');
  }
});

Properties

PropertyDefaultDescription
duration1000Duration in milliseconds
delay0Delay before the timer starts
loopfalseLoop the timer indefinitely or N times
reversedfalsePlay the timer in reverse
autoplaytrueStart automatically on creation
frameRate60Target frame rate for the timer

Callbacks

Methods

// Control playback
timer.play();
timer.pause();
timer.restart();
timer.seek(500); // Seek to 500ms
timer.reverse();