UNPKG

@bitty/animate

Version:

Create and manage animation functions with AnimationFrame API.

40 lines 1.1 kB
/** * @typedef {Object} Animation * @property {Boolean} running - Getter that indicates if animation is running. * @property {function():void} stop - Stops the animation. * @property {function():void} start - Starts the animation. */ export interface Animation { /** * A getter property that indicates if animation is running. */ readonly running: boolean; /** * Stops the animation. */ stop: () => void; /** * Starts the animation. */ start: () => void; } /** * Creates an Animation object to start and stop your animation functions. * @example * const count = 0; * * const animation = createAnimation(() => { * context.clearRect(0, 0, width, height); * context.font = "4rem monospace"; * context.textAlign = 'center'; * context.fillText(count, width / 2, height / 2); * * count++; * }); * * animation.start(); * @param {function():void} callback - A callback to handle animation. * @returns {Animation} */ export default function animate(callback: () => void): Animation; //# sourceMappingURL=animate.d.ts.map