UNPKG

1.52 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var event_emitter_1 = tslib_1.__importDefault(require("@antv/event-emitter"));
5/**
6 * G2 Chart、View、Geometry 以及 Element 等的基类,提供事件以及一些通用的方法。
7 */
8var Base = /** @class */ (function (_super) {
9 tslib_1.__extends(Base, _super);
10 function Base(cfg) {
11 var _this = _super.call(this) || this;
12 /** 标识对象是否已销毁 */
13 _this.destroyed = false;
14 var _a = cfg.visible, visible = _a === void 0 ? true : _a;
15 _this.visible = visible;
16 return _this;
17 }
18 /**
19 * 显示。
20 */
21 Base.prototype.show = function () {
22 var visible = this.visible;
23 if (!visible) {
24 this.changeVisible(true);
25 }
26 };
27 /**
28 * 隐藏。
29 */
30 Base.prototype.hide = function () {
31 var visible = this.visible;
32 if (visible) {
33 this.changeVisible(false);
34 }
35 };
36 /**
37 * 销毁。
38 */
39 Base.prototype.destroy = function () {
40 this.off();
41 this.destroyed = true;
42 };
43 /**
44 * 显示或者隐藏。
45 * @param visible
46 * @returns
47 */
48 Base.prototype.changeVisible = function (visible) {
49 if (this.visible === visible) {
50 return;
51 }
52 this.visible = visible;
53 };
54 return Base;
55}(event_emitter_1.default));
56exports.default = Base;
57//# sourceMappingURL=base.js.map
\No newline at end of file