UNPKG

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