pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
64 lines (61 loc) • 1.49 kB
JavaScript
import { ExtensionType } from '../extensions/Extensions.mjs';
import { UPDATE_PRIORITY } from '../ticker/const.mjs';
import { Ticker } from '../ticker/Ticker.mjs';
"use strict";
class TickerPlugin {
/**
* Initialize the plugin with scope of application instance
* @private
* @param {object} [options] - See application options
*/
static init(options) {
options = Object.assign({
autoStart: true,
sharedTicker: false
}, options);
Object.defineProperty(
this,
"ticker",
{
set(ticker) {
if (this._ticker) {
this._ticker.remove(this.render, this);
}
this._ticker = ticker;
if (ticker) {
ticker.add(this.render, this, UPDATE_PRIORITY.LOW);
}
},
get() {
return this._ticker;
}
}
);
this.stop = () => {
this._ticker.stop();
};
this.start = () => {
this._ticker.start();
};
this._ticker = null;
this.ticker = options.sharedTicker ? Ticker.shared : new Ticker();
if (options.autoStart) {
this.start();
}
}
/**
* Clean up the ticker, scoped to application.
* @private
*/
static destroy() {
if (this._ticker) {
const oldTicker = this._ticker;
this.ticker = null;
oldTicker.destroy();
}
}
}
/** @ignore */
TickerPlugin.extension = ExtensionType.Application;
export { TickerPlugin };
//# sourceMappingURL=TickerPlugin.mjs.map