Package Exports
- @jworkshop/animator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jworkshop/animator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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();