@jworkshop/animator

0.0.5 • Public • Published

animator

An instance class which manages animations by hooking into requestAnimationFrame (or setInterval if not available).

NPM version build status node version npm download

install

NPM

Usage

import Animator from "@jworkshop/animator";

/* Create an instance of an animator. */
let animator = new Animator();

let animateHandler = timeDiff => { ... };

/** Bind an event handler to the animate event. */
animator.add(animateHandler);

/** Unbind an event handler from the animate event. */
animator.remove(animateHandler);

/** Unbind all event handlers from the animate event. */
animator.clear();

/** Set a specific frame rate for the animation. */
animator.setFPS(fps);

/** Start the animation loop. */
animator.start();

/** Pause the animation loop. */
animator.pause();

/** Resume the animation loop. */
animator.resume();

let pauseHandler = () => { ... };

/** Bind an event handler to the pause event. */
animator.onPause(pauseHandler);

/** Unbind an event handler from the pause event. */
animator.removePause(pauseHandler);

/** Unbind all event handlers from the pause event. */
animator.clearPause();

let resumeHandler = () => { ... };

/** Bind an event handler to the resume event. */
animator.onResume(resumeHandler);

/** Unbind an event handler from the resume event. */
animator.removeResume(resumeHandler);

/** Unbind all event handlers from the resume event. */
animator.clearResume();

Package Sidebar

Install

npm i @jworkshop/animator

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

24.7 kB

Total Files

6

Last publish

Collaborators

  • jworkshop