@jworkshop/animator
v0.0.5
Published
An instance class which manages animations by hooking into requestAnimationFrame (or setInterval if not available).
Downloads
4
Maintainers
Readme
animator
An instance class which manages animations by hooking into requestAnimationFrame (or setInterval if not available).
install
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();