1 | import { __extends } from "tslib";
|
2 | import { each } from '@antv/util';
|
3 | import Action from '../base';
|
4 | import { getElementsByState } from '../util';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | var StateBase = (function (_super) {
|
12 | __extends(StateBase, _super);
|
13 | function StateBase() {
|
14 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
15 | |
16 |
|
17 |
|
18 | _this.stateName = '';
|
19 | return _this;
|
20 | }
|
21 | |
22 |
|
23 |
|
24 |
|
25 | StateBase.prototype.hasState = function (element) {
|
26 | return element.hasState(this.stateName);
|
27 | };
|
28 | |
29 |
|
30 |
|
31 |
|
32 | StateBase.prototype.setElementState = function (element, enable) {
|
33 |
|
34 | element.setState(this.stateName, enable);
|
35 | };
|
36 | |
37 |
|
38 |
|
39 | StateBase.prototype.setState = function () {
|
40 | this.setStateEnable(true);
|
41 | };
|
42 | |
43 |
|
44 |
|
45 | StateBase.prototype.clear = function () {
|
46 | var view = this.context.view;
|
47 | this.clearViewState(view);
|
48 | };
|
49 | StateBase.prototype.clearViewState = function (view) {
|
50 | var _this = this;
|
51 | var elements = getElementsByState(view, this.stateName);
|
52 | each(elements, function (el) {
|
53 | _this.setElementState(el, false);
|
54 | });
|
55 | };
|
56 | return StateBase;
|
57 | }(Action));
|
58 | export default StateBase;
|
59 |
|
\ | No newline at end of file |