gui.js 2.2 KB

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