@antv/l7-component 2.9.32 → 2.9.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,110 +1,160 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "PositionType", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _l7Core.PositionType;
14
12
  }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/control/BaseControl.ts
20
- var BaseControl_exports = {};
21
- __export(BaseControl_exports, {
22
- PositionType: () => import_l7_core2.PositionType,
23
- default: () => Control
24
13
  });
25
- module.exports = __toCommonJS(BaseControl_exports);
26
- var import_l7_core = require("@antv/l7-core");
27
- var import_l7_utils = require("@antv/l7-utils");
28
- var import_eventemitter3 = require("eventemitter3");
29
- var import_l7_core2 = require("@antv/l7-core");
14
+ exports.default = void 0;
15
+
16
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
+
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
20
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
22
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
+
24
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
+
26
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
+
28
+ var _l7Core = require("@antv/l7-core");
29
+
30
+ var _l7Utils = require("@antv/l7-utils");
31
+
32
+ var _eventemitter = require("eventemitter3");
33
+
34
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
35
+
36
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
37
+
30
38
  var controlId = 0;
31
- var Control = class extends import_eventemitter3.EventEmitter {
32
- constructor(cfg) {
33
- super();
34
- this.controlOption = {
35
- ...this.getDefault(),
36
- ...cfg || {}
37
- };
38
- }
39
- getDefault() {
40
- return {
41
- position: import_l7_core.PositionType.TOPRIGHT,
42
- name: `${controlId++}`
43
- };
39
+
40
+ var Control = /*#__PURE__*/function (_EventEmitter) {
41
+ (0, _inherits2.default)(Control, _EventEmitter);
42
+
43
+ var _super = _createSuper(Control);
44
+
45
+ function Control(cfg) {
46
+ var _this;
47
+
48
+ (0, _classCallCheck2.default)(this, Control);
49
+ _this = _super.call(this);
50
+ _this.controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault()), cfg || {});
51
+ return _this;
44
52
  }
45
- setPosition(position = import_l7_core.PositionType.BOTTOMRIGHT) {
46
- const controlService = this.controlService;
47
- if (controlService) {
48
- controlService.removeControl(this);
49
- }
50
- this.controlOption.position = position;
51
- if (controlService) {
52
- controlService.addControl(this, this.sceneContainer);
53
+
54
+ (0, _createClass2.default)(Control, [{
55
+ key: "getDefault",
56
+ value: function getDefault() {
57
+ return {
58
+ position: _l7Core.PositionType.TOPRIGHT,
59
+ name: "".concat(controlId++)
60
+ };
53
61
  }
54
- return this;
55
- }
56
- addTo(sceneContainer) {
57
- this.mapsService = sceneContainer.get(import_l7_core.TYPES.IMapService);
58
- this.renderService = sceneContainer.get(import_l7_core.TYPES.IRendererService);
59
- this.layerService = sceneContainer.get(import_l7_core.TYPES.ILayerService);
60
- this.controlService = sceneContainer.get(import_l7_core.TYPES.IControlService);
61
- this.sceneContainer = sceneContainer;
62
- this.isShow = true;
63
- this.container = this.onAdd();
64
- const container = this.container;
65
- const pos = this.controlOption.position;
66
- const corner = this.controlService.controlCorners[pos];
67
- import_l7_utils.DOM.addClass(container, "l7-control");
68
- if (pos.indexOf("bottom") !== -1) {
69
- corner.insertBefore(container, corner.firstChild);
70
- } else {
71
- corner.appendChild(container);
62
+ }, {
63
+ key: "setPosition",
64
+ value: function setPosition() {
65
+ var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _l7Core.PositionType.BOTTOMRIGHT;
66
+ // 考虑组件的自动布局,需要销毁重建
67
+ var controlService = this.controlService;
68
+
69
+ if (controlService) {
70
+ controlService.removeControl(this);
71
+ }
72
+
73
+ this.controlOption.position = position;
74
+
75
+ if (controlService) {
76
+ controlService.addControl(this, this.sceneContainer);
77
+ }
78
+
79
+ return this;
72
80
  }
73
- return this;
74
- }
75
- onAdd() {
76
- throw new Error("Method not implemented.");
77
- }
78
- onRemove() {
79
- throw new Error("Method not implemented.");
80
- }
81
- hide() {
82
- const container = this.container;
83
- import_l7_utils.DOM.addClass(container, "l7-control-hide");
84
- this.isShow = false;
85
- }
86
- show() {
87
- const container = this.container;
88
- import_l7_utils.DOM.removeClass(container, "l7-control-hide");
89
- this.isShow = true;
90
- }
91
- remove() {
92
- if (!this.mapsService) {
81
+ }, {
82
+ key: "addTo",
83
+ value: function addTo(sceneContainer) {
84
+ this.mapsService = sceneContainer.get(_l7Core.TYPES.IMapService);
85
+ this.renderService = sceneContainer.get(_l7Core.TYPES.IRendererService);
86
+ this.layerService = sceneContainer.get(_l7Core.TYPES.ILayerService);
87
+ this.controlService = sceneContainer.get(_l7Core.TYPES.IControlService);
88
+ this.sceneContainer = sceneContainer;
89
+ this.isShow = true;
90
+ this.container = this.onAdd();
91
+ var container = this.container;
92
+ var pos = this.controlOption.position;
93
+ var corner = this.controlService.controlCorners[pos];
94
+
95
+ _l7Utils.DOM.addClass(container, 'l7-control');
96
+
97
+ if (pos.indexOf('bottom') !== -1) {
98
+ corner.insertBefore(container, corner.firstChild);
99
+ } else {
100
+ corner.appendChild(container);
101
+ }
102
+
93
103
  return this;
94
104
  }
95
- import_l7_utils.DOM.remove(this.container);
96
- this.onRemove();
97
- }
98
- _refocusOnMap(e) {
99
- if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
100
- const container = this.mapsService.getContainer();
101
- if (container !== null) {
102
- container.focus();
105
+ }, {
106
+ key: "onAdd",
107
+ value: function onAdd() {
108
+ throw new Error('Method not implemented.');
109
+ }
110
+ }, {
111
+ key: "onRemove",
112
+ value: function onRemove() {
113
+ throw new Error('Method not implemented.');
114
+ }
115
+ }, {
116
+ key: "hide",
117
+ value: function hide() {
118
+ var container = this.container;
119
+
120
+ _l7Utils.DOM.addClass(container, 'l7-control-hide');
121
+
122
+ this.isShow = false;
123
+ }
124
+ }, {
125
+ key: "show",
126
+ value: function show() {
127
+ var container = this.container;
128
+
129
+ _l7Utils.DOM.removeClass(container, 'l7-control-hide');
130
+
131
+ this.isShow = true;
132
+ }
133
+ }, {
134
+ key: "remove",
135
+ value: function remove() {
136
+ if (!this.mapsService) {
137
+ return this;
138
+ }
139
+
140
+ _l7Utils.DOM.remove(this.container);
141
+
142
+ this.onRemove();
143
+ }
144
+ }, {
145
+ key: "_refocusOnMap",
146
+ value: function _refocusOnMap(e) {
147
+ // if map exists and event is not a keyboard event
148
+ if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
149
+ var container = this.mapsService.getContainer();
150
+
151
+ if (container !== null) {
152
+ container.focus();
153
+ }
103
154
  }
104
155
  }
105
- }
106
- };
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
109
- PositionType
110
- });
156
+ }]);
157
+ return Control;
158
+ }(_eventemitter.EventEmitter);
159
+
160
+ exports.default = Control;