gui.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.GUI = void 0;
  4. var tslib_1 = require("tslib");
  5. var shapes_1 = require("../shapes");
  6. var util_1 = require("../util");
  7. function applyVisibility() {
  8. (0, util_1.visibility)(this, this.attributes.visibility !== 'hidden');
  9. }
  10. var GUI = /** @class */ (function (_super) {
  11. tslib_1.__extends(GUI, _super);
  12. function GUI(options, defaultStyleProps) {
  13. if (defaultStyleProps === void 0) { defaultStyleProps = {}; }
  14. var _this = _super.call(this, (0, util_1.deepAssign)({}, { style: defaultStyleProps }, options)) || this;
  15. _this.initialized = false;
  16. _this._defaultOptions = defaultStyleProps;
  17. return _this;
  18. }
  19. Object.defineProperty(GUI.prototype, "offscreenGroup", {
  20. get: function () {
  21. if (!this._offscreen)
  22. this._offscreen = (0, util_1.createOffscreenGroup)(this);
  23. return this._offscreen;
  24. },
  25. enumerable: false,
  26. configurable: true
  27. });
  28. Object.defineProperty(GUI.prototype, "defaultOptions", {
  29. get: function () {
  30. return this._defaultOptions;
  31. },
  32. enumerable: false,
  33. configurable: true
  34. });
  35. GUI.prototype.connectedCallback = function () {
  36. this.render(this.attributes, this);
  37. this.bindEvents(this.attributes, this);
  38. // applyVisibility.call(this);
  39. this.initialized = true;
  40. };
  41. GUI.prototype.disconnectedCallback = function () {
  42. var _a;
  43. (_a = this._offscreen) === null || _a === void 0 ? void 0 : _a.destroy();
  44. };
  45. GUI.prototype.attributeChangedCallback = function (name) {
  46. if (name === 'visibility') {
  47. applyVisibility.call(this);
  48. }
  49. };
  50. GUI.prototype.update = function (attr, animate) {
  51. var _a;
  52. if (attr === void 0) { attr = {}; }
  53. this.attr((0, util_1.deepAssign)({}, this.attributes, attr));
  54. return (_a = this.render) === null || _a === void 0 ? void 0 : _a.call(this, this.attributes, this, animate);
  55. };
  56. GUI.prototype.clear = function () {
  57. this.removeChildren();
  58. };
  59. GUI.prototype.bindEvents = function (attributes, container) { };
  60. return GUI;
  61. }(shapes_1.CustomElement));
  62. exports.GUI = GUI;
  63. //# sourceMappingURL=gui.js.map