UNPKG

g2o-player

Version:
54 lines (51 loc) 1.73 kB
/** * g2o-player 1.0.0-alpha.0 * (c) David Geo Holmes david.geo.holmes@gmail.com * Released under the MIT License. */ System.register(['g2o-reactive'], (function (exports) { 'use strict'; var effect; return { setters: [function (module) { effect = module.effect; }], execute: (function () { class Player { #board; #frameCount; /** * The handle of the last frame requested. */ #handle = null; constructor(board, callback) { this.#board = board; this.#frameCount = effect(() => { callback(board.frameCount); }); } dispose() { if (this.#frameCount) { this.#frameCount.dispose(); } } play() { // eslint-disable-next-line @typescript-eslint/no-unused-vars const animate = (timestamp) => { this.#handle = null; this.#board.update(); this.#handle = window.requestAnimationFrame(animate); }; this.#handle = window.requestAnimationFrame(animate); } pause() { if (typeof this.#handle === 'number') { window.cancelAnimationFrame(this.#handle); this.#handle = null; } } } exports("Player", Player); }) }; })); //# sourceMappingURL=index.js.map