@robotlegsjs/pixi-palidor
Version:
A RobotlegsJS View Manager Extension for PixiJS
88 lines • 3.47 kB
JavaScript
;
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
exports.PixiContainerController = void 0;
var tslib_1 = require("tslib");
var core_1 = require("@robotlegsjs/core");
var pixi_1 = require("@robotlegsjs/pixi");
var pixi_js_1 = require("pixi.js");
var PixiContainerController = /** @class */ (function () {
function PixiContainerController(contextView) {
this._floatingViews = [];
this._root = contextView.view;
this.createLayers();
}
Object.defineProperty(PixiContainerController.prototype, "staticLayer", {
get: function () {
return this._staticLayer;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PixiContainerController.prototype, "dynamicLayer", {
get: function () {
return this._dynamicLayer;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PixiContainerController.prototype, "currentView", {
get: function () {
return this._currentView;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PixiContainerController.prototype, "floatingViews", {
get: function () {
return this._floatingViews;
},
enumerable: false,
configurable: true
});
PixiContainerController.prototype.addView = function (view) {
if (this._floatingViews.indexOf(view) === -1) {
this._floatingViews.push(view);
this._dynamicLayer.addChild(view);
}
};
PixiContainerController.prototype.changeView = function (view) {
this._currentView = view;
this._staticLayer.addChildAt(view, 0);
};
PixiContainerController.prototype.removeCurrentView = function () {
if (this._currentView !== undefined) {
this._staticLayer.removeChild(this._currentView);
this._currentView = undefined;
}
};
PixiContainerController.prototype.removeLastFloatingViewAdded = function () {
if (this._floatingViews.length > 0) {
this._dynamicLayer.removeChild(this._floatingViews.pop());
}
};
PixiContainerController.prototype.removeAllFloatingViews = function () {
while (this._floatingViews.length > 0) {
this._dynamicLayer.removeChild(this._floatingViews.pop());
}
};
PixiContainerController.prototype.createLayers = function () {
this._staticLayer = new pixi_js_1.Container();
this._dynamicLayer = new pixi_js_1.Container();
this._root.addChild(this._staticLayer);
this._root.addChild(this._dynamicLayer);
};
PixiContainerController = tslib_1.__decorate([
core_1.injectable(),
tslib_1.__param(0, core_1.inject(pixi_1.IContextView)),
tslib_1.__metadata("design:paramtypes", [Object])
], PixiContainerController);
return PixiContainerController;
}());
exports.PixiContainerController = PixiContainerController;
//# sourceMappingURL=PixiContainerController.js.map