Files
nothoughts/node_modules/pixi.js/lib/app/TickerPlugin.mjs
2025-08-04 18:57:35 +02:00

66 lines
1.5 KiB
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
* @static
* @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.
* @static
* @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