@antv/l7-component 2.9.34 → 2.9.36-alpha.1

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.
Files changed (110) hide show
  1. package/es/assets/iconfont/iconfont.js +53 -0
  2. package/es/constants/index.d.ts +60 -0
  3. package/es/constants/index.js +60 -0
  4. package/es/control/baseControl/buttonControl.d.ts +59 -0
  5. package/es/control/baseControl/buttonControl.js +191 -0
  6. package/es/control/baseControl/control.d.ts +106 -0
  7. package/es/control/baseControl/control.js +301 -0
  8. package/es/control/baseControl/index.d.ts +4 -0
  9. package/es/control/baseControl/index.js +4 -0
  10. package/es/control/baseControl/popperControl.d.ts +26 -0
  11. package/es/control/baseControl/popperControl.js +131 -0
  12. package/es/control/baseControl/selectControl.d.ts +46 -0
  13. package/es/control/baseControl/selectControl.js +232 -0
  14. package/es/control/exportImage.d.ts +18 -0
  15. package/es/control/exportImage.js +163 -0
  16. package/es/control/fullscreen.d.ts +19 -0
  17. package/es/control/fullscreen.js +151 -0
  18. package/es/control/geoLocate.d.ts +16 -0
  19. package/es/control/geoLocate.js +139 -0
  20. package/es/control/layerControl.d.ts +21 -0
  21. package/es/control/layerControl.js +172 -0
  22. package/es/control/logo.d.ts +10 -6
  23. package/es/control/logo.js +41 -11
  24. package/es/control/mapTheme.d.ts +10 -0
  25. package/es/control/mapTheme.js +135 -0
  26. package/es/control/mouseLocation.d.ts +15 -0
  27. package/es/control/mouseLocation.js +104 -0
  28. package/es/control/scale.d.ts +20 -10
  29. package/es/control/scale.js +77 -53
  30. package/es/control/zoom.d.ts +21 -10
  31. package/es/control/zoom.js +76 -49
  32. package/es/css/button.less +70 -0
  33. package/es/css/control.less +71 -0
  34. package/es/css/index.css +567 -0
  35. package/es/css/index.less +12 -0
  36. package/es/css/l7.less +60 -0
  37. package/es/css/layerPopup.less +8 -0
  38. package/es/css/logo.less +18 -0
  39. package/es/css/mouseLocation.less +9 -0
  40. package/es/css/popper.less +64 -0
  41. package/es/css/popup.less +169 -0
  42. package/es/css/scale.less +34 -0
  43. package/es/css/select.less +86 -0
  44. package/es/css/variables.less +28 -0
  45. package/es/css/zoom.less +21 -0
  46. package/es/images/logo.png +0 -0
  47. package/es/images/quanping.svg +12 -0
  48. package/es/index.d.ts +15 -8
  49. package/es/index.js +15 -9
  50. package/es/interface.d.ts +1 -20
  51. package/es/popup/layerPopup.d.ts +78 -0
  52. package/es/popup/layerPopup.js +308 -0
  53. package/es/popup/popup.d.ts +147 -0
  54. package/es/popup/popup.js +636 -0
  55. package/es/utils/icon.d.ts +1 -0
  56. package/es/utils/icon.js +9 -0
  57. package/es/utils/popper.d.ts +75 -0
  58. package/es/utils/popper.js +286 -0
  59. package/es/utils/screenfull.d.ts +2 -0
  60. package/es/utils/screenfull.js +157 -0
  61. package/lib/assets/iconfont/iconfont.js +55 -0
  62. package/lib/constants/index.js +68 -0
  63. package/lib/control/baseControl/buttonControl.js +207 -0
  64. package/lib/control/baseControl/control.js +333 -0
  65. package/lib/control/baseControl/index.js +57 -0
  66. package/lib/control/baseControl/popperControl.js +142 -0
  67. package/lib/control/baseControl/selectControl.js +253 -0
  68. package/lib/control/exportImage.js +177 -0
  69. package/lib/control/fullscreen.js +164 -0
  70. package/lib/control/geoLocate.js +154 -0
  71. package/lib/control/layerControl.js +182 -0
  72. package/lib/control/logo.js +50 -23
  73. package/lib/control/mapTheme.js +151 -0
  74. package/lib/control/mouseLocation.js +120 -0
  75. package/lib/control/scale.js +82 -62
  76. package/lib/control/zoom.js +78 -59
  77. package/lib/css/button.less +70 -0
  78. package/lib/css/control.less +71 -0
  79. package/lib/css/index.css +567 -0
  80. package/lib/css/index.less +12 -0
  81. package/lib/css/l7.less +60 -0
  82. package/lib/css/layerPopup.less +8 -0
  83. package/lib/css/logo.less +18 -0
  84. package/lib/css/mouseLocation.less +9 -0
  85. package/lib/css/popper.less +64 -0
  86. package/lib/css/popup.less +169 -0
  87. package/lib/css/scale.less +34 -0
  88. package/lib/css/select.less +86 -0
  89. package/lib/css/variables.less +28 -0
  90. package/lib/css/zoom.less +21 -0
  91. package/lib/images/logo.png +0 -0
  92. package/lib/images/quanping.svg +12 -0
  93. package/lib/index.js +165 -50
  94. package/lib/popup/layerPopup.js +317 -0
  95. package/lib/popup/popup.js +651 -0
  96. package/lib/utils/icon.js +18 -0
  97. package/lib/utils/popper.js +297 -0
  98. package/lib/utils/screenfull.js +167 -0
  99. package/package.json +8 -5
  100. package/es/control/BaseControl.d.ts +0 -27
  101. package/es/control/BaseControl.js +0 -134
  102. package/es/control/layer.d.ts +0 -38
  103. package/es/control/layer.js +0 -340
  104. package/es/css/l7.css +0 -502
  105. package/es/popup.d.ts +0 -35
  106. package/es/popup.js +0 -300
  107. package/lib/control/BaseControl.js +0 -160
  108. package/lib/control/layer.js +0 -362
  109. package/lib/css/l7.css +0 -502
  110. package/lib/popup.js +0 -317
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Popper = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _l7Utils = require("@antv/l7-utils");
27
+
28
+ var _eventemitter = require("eventemitter3");
29
+
30
+ 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); }; }
31
+
32
+ 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; } }
33
+
34
+ var Popper = /*#__PURE__*/function (_EventEmitter) {
35
+ (0, _inherits2.default)(Popper, _EventEmitter);
36
+
37
+ var _super = _createSuper(Popper);
38
+
39
+ function Popper(button, option) {
40
+ var _this;
41
+
42
+ (0, _classCallCheck2.default)(this, Popper);
43
+ _this = _super.call(this);
44
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isShow", false);
45
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timeout", null);
46
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "show", function () {
47
+ if (_this.isShow || !_this.contentDOM.innerHTML) {
48
+ return (0, _assertThisInitialized2.default)(_this);
49
+ }
50
+
51
+ _this.resetPopperPosition();
52
+
53
+ _l7Utils.DOM.removeClass(_this.popperDOM, 'l7-popper-hide');
54
+
55
+ _this.isShow = true;
56
+
57
+ if (_this.option.unique) {
58
+ // console.log(Popper.conflictPopperList.length);
59
+ Popper.conflictPopperList.forEach(function (popper) {
60
+ if (popper !== (0, _assertThisInitialized2.default)(_this) && popper.isShow) {
61
+ popper.hide();
62
+ }
63
+ });
64
+ }
65
+
66
+ _this.emit('show');
67
+
68
+ return (0, _assertThisInitialized2.default)(_this);
69
+ });
70
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hide", function () {
71
+ if (!_this.isShow) {
72
+ return (0, _assertThisInitialized2.default)(_this);
73
+ }
74
+
75
+ _l7Utils.DOM.addClass(_this.popperDOM, 'l7-popper-hide');
76
+
77
+ _this.isShow = false;
78
+
79
+ _this.emit('hide');
80
+
81
+ return (0, _assertThisInitialized2.default)(_this);
82
+ });
83
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setHideTimeout", function () {
84
+ if (_this.timeout) {
85
+ return;
86
+ }
87
+
88
+ _this.timeout = window.setTimeout(function () {
89
+ if (!_this.isShow) {
90
+ return;
91
+ }
92
+
93
+ _this.hide();
94
+
95
+ _this.timeout = null;
96
+ }, 300);
97
+ });
98
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearHideTimeout", function () {
99
+ if (_this.timeout) {
100
+ window.clearTimeout(_this.timeout);
101
+ _this.timeout = null;
102
+ }
103
+ });
104
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnClick", function () {
105
+ if (_this.isShow) {
106
+ _this.hide();
107
+ } else {
108
+ _this.show();
109
+ }
110
+ });
111
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnMouseLeave", function () {
112
+ _this.setHideTimeout();
113
+ });
114
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnMouseMove", function () {
115
+ _this.clearHideTimeout();
116
+
117
+ if (_this.isShow) {
118
+ return;
119
+ }
120
+
121
+ _this.show();
122
+ });
123
+ _this.button = button;
124
+ _this.option = option;
125
+
126
+ _this.init();
127
+
128
+ if (option.unique) {
129
+ Popper.conflictPopperList.push((0, _assertThisInitialized2.default)(_this));
130
+ }
131
+
132
+ return _this;
133
+ }
134
+
135
+ (0, _createClass2.default)(Popper, [{
136
+ key: "buttonRect",
137
+ get: function get() {
138
+ return this.button.getBoundingClientRect();
139
+ }
140
+ }, {
141
+ key: "getPopperDOM",
142
+ value: function getPopperDOM() {
143
+ return this.popperDOM;
144
+ }
145
+ }, {
146
+ key: "getIsShow",
147
+ value: function getIsShow() {
148
+ return this.isShow;
149
+ }
150
+ }, {
151
+ key: "getContent",
152
+ value: function getContent() {
153
+ return this.content;
154
+ }
155
+ }, {
156
+ key: "setContent",
157
+ value: function setContent(content) {
158
+ if (typeof content === 'string') {
159
+ this.contentDOM.innerHTML = content;
160
+ } else if (content instanceof HTMLElement) {
161
+ _l7Utils.DOM.clearChildren(this.contentDOM);
162
+
163
+ this.contentDOM.appendChild(content);
164
+ }
165
+
166
+ this.content = content;
167
+ }
168
+ }, {
169
+ key: "init",
170
+ value: function init() {
171
+ var trigger = this.option.trigger;
172
+ this.popperDOM = this.createPopper();
173
+
174
+ if (trigger === 'click') {
175
+ this.button.addEventListener('click', this.onBtnClick);
176
+ } else {
177
+ this.button.addEventListener('mousemove', this.onBtnMouseMove);
178
+ this.button.addEventListener('mouseleave', this.onBtnMouseLeave);
179
+ this.popperDOM.addEventListener('mousemove', this.onBtnMouseMove);
180
+ this.popperDOM.addEventListener('mouseleave', this.onBtnMouseLeave);
181
+ }
182
+ }
183
+ }, {
184
+ key: "destroy",
185
+ value: function destroy() {
186
+ this.button.removeEventListener('click', this.onBtnClick);
187
+ this.button.removeEventListener('mousemove', this.onBtnMouseMove);
188
+ this.button.removeEventListener('mousemove', this.onBtnMouseLeave);
189
+ this.popperDOM.removeEventListener('mousemove', this.onBtnMouseMove);
190
+ this.popperDOM.removeEventListener('mouseleave', this.onBtnMouseLeave);
191
+
192
+ _l7Utils.DOM.remove(this.popperDOM);
193
+ }
194
+ }, {
195
+ key: "resetPopperPosition",
196
+ value: function resetPopperPosition() {
197
+ var popperStyleObj = {};
198
+ var _this$option = this.option,
199
+ container = _this$option.container,
200
+ _this$option$offset = _this$option.offset,
201
+ offset = _this$option$offset === void 0 ? [0, 0] : _this$option$offset,
202
+ placement = _this$option.placement;
203
+
204
+ var _offset = (0, _slicedToArray2.default)(offset, 2),
205
+ offsetX = _offset[0],
206
+ offsetY = _offset[1];
207
+
208
+ var buttonRect = this.button.getBoundingClientRect();
209
+ var containerRect = container.getBoundingClientRect();
210
+
211
+ var _DOM$getDiffRect = _l7Utils.DOM.getDiffRect(buttonRect, containerRect),
212
+ left = _DOM$getDiffRect.left,
213
+ right = _DOM$getDiffRect.right,
214
+ top = _DOM$getDiffRect.top,
215
+ bottom = _DOM$getDiffRect.bottom;
216
+
217
+ var isTransformX = false;
218
+ var isTransformY = false;
219
+
220
+ if (/^(left|right)/.test(placement)) {
221
+ if (placement.includes('left')) {
222
+ popperStyleObj.right = "".concat(buttonRect.width + right, "px");
223
+ } else if (placement.includes('right')) {
224
+ popperStyleObj.left = "".concat(buttonRect.width + left, "px");
225
+ }
226
+
227
+ if (placement.includes('start')) {
228
+ popperStyleObj.top = "".concat(top, "px");
229
+ } else if (placement.includes('end')) {
230
+ popperStyleObj.bottom = "".concat(bottom, "px");
231
+ } else {
232
+ popperStyleObj.top = "".concat(top + buttonRect.height / 2, "px");
233
+ isTransformY = true;
234
+ popperStyleObj.transform = "translate(".concat(offsetX, "px, calc(").concat(offsetY, "px - 50%))");
235
+ }
236
+ } else if (/^(top|bottom)/.test(placement)) {
237
+ if (placement.includes('top')) {
238
+ popperStyleObj.bottom = "".concat(buttonRect.height + bottom, "px");
239
+ } else if (placement.includes('bottom')) {
240
+ popperStyleObj.top = "".concat(buttonRect.height + top, "px");
241
+ }
242
+
243
+ if (placement.includes('start')) {
244
+ popperStyleObj.left = "".concat(left, "px");
245
+ } else if (placement.includes('end')) {
246
+ popperStyleObj.right = "".concat(right, "px");
247
+ } else {
248
+ popperStyleObj.left = "".concat(left + buttonRect.width / 2, "px");
249
+ isTransformX = true;
250
+ popperStyleObj.transform = "translate(calc(".concat(offsetX, "px - 50%), ").concat(offsetY, "px)");
251
+ }
252
+ }
253
+
254
+ popperStyleObj.transform = "translate(calc(".concat(offsetX, "px - ").concat(isTransformX ? '50%' : '0%', "), calc(").concat(offsetY, "px - ").concat(isTransformY ? '50%' : '0%', ")");
255
+ var posList = placement.split('-');
256
+
257
+ if (posList.length) {
258
+ _l7Utils.DOM.addClass(this.popperDOM, posList.map(function (pos) {
259
+ return "l7-popper-".concat(pos);
260
+ }).join(' '));
261
+ }
262
+
263
+ _l7Utils.DOM.addStyle(this.popperDOM, _l7Utils.DOM.css2Style(popperStyleObj));
264
+ }
265
+ }, {
266
+ key: "createPopper",
267
+ value: function createPopper() {
268
+ var _this$option2 = this.option,
269
+ container = _this$option2.container,
270
+ _this$option2$classNa = _this$option2.className,
271
+ className = _this$option2$classNa === void 0 ? '' : _this$option2$classNa,
272
+ content = _this$option2.content;
273
+
274
+ var popper = _l7Utils.DOM.create('div', "l7-popper l7-popper-hide ".concat(className));
275
+
276
+ var popperContent = _l7Utils.DOM.create('div', 'l7-popper-content');
277
+
278
+ var popperArrow = _l7Utils.DOM.create('div', 'l7-popper-arrow');
279
+
280
+ popper.appendChild(popperContent);
281
+ popper.appendChild(popperArrow);
282
+ container.appendChild(popper);
283
+ this.popperDOM = popper;
284
+ this.contentDOM = popperContent;
285
+
286
+ if (content) {
287
+ this.setContent(content);
288
+ }
289
+
290
+ return popper;
291
+ }
292
+ }]);
293
+ return Popper;
294
+ }(_eventemitter.EventEmitter);
295
+
296
+ exports.Popper = Popper;
297
+ (0, _defineProperty2.default)(Popper, "conflictPopperList", []);
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
+
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
+
18
+ // @ts-nocheck
19
+ var methodMap = [['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'], // New WebKit
20
+ ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'], // Old WebKit
21
+ ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'], ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'], ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
22
+
23
+ var nativeAPI = function () {
24
+ if (typeof document === 'undefined') {
25
+ return false;
26
+ }
27
+
28
+ var unprefixedMethods = methodMap[0];
29
+ var returnValue = {};
30
+
31
+ var _iterator = _createForOfIteratorHelper(methodMap),
32
+ _step;
33
+
34
+ try {
35
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
+ var methodList = _step.value;
37
+ var exitFullscreenMethod = methodList === null || methodList === void 0 ? void 0 : methodList[1];
38
+
39
+ if (exitFullscreenMethod in document) {
40
+ var _iterator2 = _createForOfIteratorHelper(methodList.entries()),
41
+ _step2;
42
+
43
+ try {
44
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
45
+ var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
46
+ index = _step2$value[0],
47
+ method = _step2$value[1];
48
+
49
+ returnValue[unprefixedMethods[index]] = method;
50
+ }
51
+ } catch (err) {
52
+ _iterator2.e(err);
53
+ } finally {
54
+ _iterator2.f();
55
+ }
56
+
57
+ return returnValue;
58
+ }
59
+ }
60
+ } catch (err) {
61
+ _iterator.e(err);
62
+ } finally {
63
+ _iterator.f();
64
+ }
65
+
66
+ return false;
67
+ }();
68
+
69
+ var eventNameMap = {
70
+ change: nativeAPI.fullscreenchange,
71
+ error: nativeAPI.fullscreenerror
72
+ };
73
+ var screenfull = {
74
+ // eslint-disable-next-line default-param-last
75
+ request: function request() {
76
+ var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.documentElement;
77
+ var options = arguments.length > 1 ? arguments[1] : undefined;
78
+ return new Promise(function (resolve, reject) {
79
+ var onFullScreenEntered = function onFullScreenEntered() {
80
+ screenfull.off('change', onFullScreenEntered);
81
+ resolve();
82
+ };
83
+
84
+ screenfull.on('change', onFullScreenEntered);
85
+ var returnPromise = element[nativeAPI.requestFullscreen](options);
86
+
87
+ if (returnPromise instanceof Promise) {
88
+ returnPromise.then(onFullScreenEntered).catch(reject);
89
+ }
90
+ });
91
+ },
92
+ exit: function exit() {
93
+ return new Promise(function (resolve, reject) {
94
+ if (!screenfull.isFullscreen) {
95
+ resolve();
96
+ return;
97
+ }
98
+
99
+ var onFullScreenExit = function onFullScreenExit() {
100
+ screenfull.off('change', onFullScreenExit);
101
+ resolve();
102
+ };
103
+
104
+ screenfull.on('change', onFullScreenExit);
105
+ var returnPromise = document[nativeAPI.exitFullscreen]();
106
+
107
+ if (returnPromise instanceof Promise) {
108
+ returnPromise.then(onFullScreenExit).catch(reject);
109
+ }
110
+ });
111
+ },
112
+ toggle: function toggle(element, options) {
113
+ return screenfull.isFullscreen ? screenfull.exit() : screenfull.request(element, options);
114
+ },
115
+ onchange: function onchange(callback) {
116
+ screenfull.on('change', callback);
117
+ },
118
+ onerror: function onerror(callback) {
119
+ screenfull.on('error', callback);
120
+ },
121
+ on: function on(event, callback) {
122
+ var eventName = eventNameMap[event];
123
+
124
+ if (eventName) {
125
+ document.addEventListener(eventName, callback, false);
126
+ }
127
+ },
128
+ off: function off(event, callback) {
129
+ var eventName = eventNameMap[event];
130
+
131
+ if (eventName) {
132
+ document.removeEventListener(eventName, callback, false);
133
+ }
134
+ },
135
+ raw: nativeAPI
136
+ };
137
+ Object.defineProperties(screenfull, {
138
+ isFullscreen: {
139
+ get: function get() {
140
+ return Boolean(document[nativeAPI.fullscreenElement]);
141
+ }
142
+ },
143
+ element: {
144
+ enumerable: true,
145
+ get: function get() {
146
+ var _document$nativeAPI$f;
147
+
148
+ return (_document$nativeAPI$f = document[nativeAPI.fullscreenElement]) !== null && _document$nativeAPI$f !== void 0 ? _document$nativeAPI$f : undefined;
149
+ }
150
+ },
151
+ isEnabled: {
152
+ enumerable: true,
153
+ // Coerce to boolean in case of old WebKit.
154
+ get: function get() {
155
+ return Boolean(document[nativeAPI.fullscreenEnabled]);
156
+ }
157
+ }
158
+ });
159
+
160
+ if (!nativeAPI) {
161
+ screenfull = {
162
+ isEnabled: false
163
+ };
164
+ }
165
+
166
+ var _default = screenfull;
167
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.9.34",
3
+ "version": "2.9.36-alpha.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -13,6 +13,7 @@
13
13
  ],
14
14
  "scripts": {
15
15
  "tsc": "tsc --project tsconfig.build.json",
16
+ "less": "lessc src/css/index.less src/css/index.css",
16
17
  "clean": "rimraf dist; rimraf es; rimraf lib;",
17
18
  "build": "father build",
18
19
  "build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
@@ -25,8 +26,8 @@
25
26
  "author": "lzxue",
26
27
  "license": "ISC",
27
28
  "dependencies": {
28
- "@antv/l7-core": "2.9.34",
29
- "@antv/l7-utils": "2.9.34",
29
+ "@antv/l7-core": "2.9.36-alpha.1",
30
+ "@antv/l7-utils": "2.9.36-alpha.1",
30
31
  "@babel/runtime": "^7.7.7",
31
32
  "eventemitter3": "^4.0.0",
32
33
  "inversify": "^5.0.1",
@@ -35,9 +36,11 @@
35
36
  "supercluster": "^7.0.0"
36
37
  },
37
38
  "devDependencies": {
38
- "@antv/l7-test-utils": "2.9.34"
39
+ "@antv/l7-test-utils": "2.9.36-alpha.1",
40
+ "gcoord": "^0.3.2",
41
+ "less": "^4.1.3"
39
42
  },
40
- "gitHead": "5e0fdaf978907383aedd4ba77a8508e7b3b87671",
43
+ "gitHead": "dafb82e5eb2cf73db95d8dbdcef63d4ad5f99554",
41
44
  "publishConfig": {
42
45
  "access": "public"
43
46
  }
@@ -1,27 +0,0 @@
1
- import { IControlOption, IControlService, ILayerService, IMapService, IRendererService, PositionType } from '@antv/l7-core';
2
- import { EventEmitter } from 'eventemitter3';
3
- import { Container } from 'inversify';
4
- export { PositionType } from '@antv/l7-core';
5
- export default class Control extends EventEmitter {
6
- controlOption: IControlOption;
7
- protected container: HTMLElement;
8
- protected sceneContainer: Container;
9
- protected mapsService: IMapService;
10
- protected renderService: IRendererService;
11
- protected layerService: ILayerService;
12
- protected controlService: IControlService;
13
- private isShow;
14
- constructor(cfg?: Partial<IControlOption>);
15
- getDefault(): {
16
- position: PositionType;
17
- name: string;
18
- };
19
- setPosition(position?: PositionType): this;
20
- addTo(sceneContainer: Container): this;
21
- onAdd(): HTMLElement;
22
- onRemove(): void;
23
- hide(): void;
24
- show(): void;
25
- remove(): this | undefined;
26
- _refocusOnMap(e: MouseEvent): void;
27
- }
@@ -1,134 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
-
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
-
10
- 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; } }
11
-
12
- import { PositionType, TYPES } from '@antv/l7-core';
13
- import { DOM } from '@antv/l7-utils';
14
- import { EventEmitter } from 'eventemitter3';
15
- export { PositionType } from '@antv/l7-core';
16
- var controlId = 0;
17
-
18
- var Control = /*#__PURE__*/function (_EventEmitter) {
19
- _inherits(Control, _EventEmitter);
20
-
21
- var _super = _createSuper(Control);
22
-
23
- function Control(cfg) {
24
- var _this;
25
-
26
- _classCallCheck(this, Control);
27
-
28
- _this = _super.call(this);
29
- _this.controlOption = _objectSpread(_objectSpread({}, _this.getDefault()), cfg || {});
30
- return _this;
31
- }
32
-
33
- _createClass(Control, [{
34
- key: "getDefault",
35
- value: function getDefault() {
36
- return {
37
- position: PositionType.TOPRIGHT,
38
- name: "".concat(controlId++)
39
- };
40
- }
41
- }, {
42
- key: "setPosition",
43
- value: function setPosition() {
44
- var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PositionType.BOTTOMRIGHT;
45
- // 考虑组件的自动布局,需要销毁重建
46
- var controlService = this.controlService;
47
-
48
- if (controlService) {
49
- controlService.removeControl(this);
50
- }
51
-
52
- this.controlOption.position = position;
53
-
54
- if (controlService) {
55
- controlService.addControl(this, this.sceneContainer);
56
- }
57
-
58
- return this;
59
- }
60
- }, {
61
- key: "addTo",
62
- value: function addTo(sceneContainer) {
63
- this.mapsService = sceneContainer.get(TYPES.IMapService);
64
- this.renderService = sceneContainer.get(TYPES.IRendererService);
65
- this.layerService = sceneContainer.get(TYPES.ILayerService);
66
- this.controlService = sceneContainer.get(TYPES.IControlService);
67
- this.sceneContainer = sceneContainer;
68
- this.isShow = true;
69
- this.container = this.onAdd();
70
- var container = this.container;
71
- var pos = this.controlOption.position;
72
- var corner = this.controlService.controlCorners[pos];
73
- DOM.addClass(container, 'l7-control');
74
-
75
- if (pos.indexOf('bottom') !== -1) {
76
- corner.insertBefore(container, corner.firstChild);
77
- } else {
78
- corner.appendChild(container);
79
- }
80
-
81
- return this;
82
- }
83
- }, {
84
- key: "onAdd",
85
- value: function onAdd() {
86
- throw new Error('Method not implemented.');
87
- }
88
- }, {
89
- key: "onRemove",
90
- value: function onRemove() {
91
- throw new Error('Method not implemented.');
92
- }
93
- }, {
94
- key: "hide",
95
- value: function hide() {
96
- var container = this.container;
97
- DOM.addClass(container, 'l7-control-hide');
98
- this.isShow = false;
99
- }
100
- }, {
101
- key: "show",
102
- value: function show() {
103
- var container = this.container;
104
- DOM.removeClass(container, 'l7-control-hide');
105
- this.isShow = true;
106
- }
107
- }, {
108
- key: "remove",
109
- value: function remove() {
110
- if (!this.mapsService) {
111
- return this;
112
- }
113
-
114
- DOM.remove(this.container);
115
- this.onRemove();
116
- }
117
- }, {
118
- key: "_refocusOnMap",
119
- value: function _refocusOnMap(e) {
120
- // if map exists and event is not a keyboard event
121
- if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
122
- var container = this.mapsService.getContainer();
123
-
124
- if (container !== null) {
125
- container.focus();
126
- }
127
- }
128
- }
129
- }]);
130
-
131
- return Control;
132
- }(EventEmitter);
133
-
134
- export { Control as default };