@antv/l7-component 2.11.1 → 2.11.3

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.
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = exports.Popup = void 0;
9
9
 
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
11
 
14
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -181,11 +179,6 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
181
179
  * @protected
182
180
  */
183
181
 
184
- /**
185
- * popup 内容标题
186
- * @protected
187
- */
188
-
189
182
  /**
190
183
  * 气泡箭头对应的 DOM
191
184
  * @protected
@@ -227,7 +220,8 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
227
220
  this.updateFollowCursor();
228
221
  var _this$popupOption2 = this.popupOption,
229
222
  html = _this$popupOption2.html,
230
- text = _this$popupOption2.text;
223
+ text = _this$popupOption2.text,
224
+ title = _this$popupOption2.title;
231
225
 
232
226
  if (html) {
233
227
  this.setHTML(html);
@@ -235,6 +229,10 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
235
229
  this.setText(text);
236
230
  }
237
231
 
232
+ if (title) {
233
+ this.setTitle(title);
234
+ }
235
+
238
236
  this.emit('open');
239
237
  return this;
240
238
  } // 移除popup
@@ -283,9 +281,10 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
283
281
  }, {
284
282
  key: "setOptions",
285
283
  value: function setOptions(option) {
284
+ this.show();
286
285
  this.popupOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.popupOption), option);
287
286
 
288
- if (this.checkUpdateOption(option, ['closeButton', 'closeButtonOffsets', 'maxWidth', 'anchor', 'stopPropagation', 'className', 'style', 'lngLat', 'offsets', 'title'])) {
287
+ if (this.checkUpdateOption(option, ['closeButton', 'closeButtonOffsets', 'maxWidth', 'anchor', 'stopPropagation', 'className', 'style', 'lngLat', 'offsets'])) {
289
288
  if (this.container) {
290
289
  _l7Utils.DOM.remove(this.container); // @ts-ignore
291
290
 
@@ -293,6 +292,10 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
293
292
  this.container = undefined;
294
293
  }
295
294
 
295
+ if (this.popupOption.title) {
296
+ this.setTitle(this.popupOption.title);
297
+ }
298
+
296
299
  if (this.popupOption.html) {
297
300
  this.setHTML(this.popupOption.html);
298
301
  } else if (this.popupOption.text) {
@@ -318,9 +321,12 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
318
321
  this.setText(option.text);
319
322
  }
320
323
 
324
+ if (this.checkUpdateOption(option, ['title'])) {
325
+ this.setTitle(option.title);
326
+ }
327
+
321
328
  if (this.checkUpdateOption(option, ['lngLat']) && option.lngLat) {
322
329
  this.setLnglat(option.lngLat);
323
- this.show();
324
330
  }
325
331
 
326
332
  return this;
@@ -376,7 +382,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
376
382
  key: "setHTML",
377
383
  value: function setHTML(html) {
378
384
  this.popupOption.html = html;
379
- return this.setDOMContent(this.getPopupHTMLFragment(html));
385
+ return this.setDOMContent(html);
380
386
  }
381
387
  /**
382
388
  * 设置 Popup 展示文本
@@ -389,6 +395,31 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
389
395
  this.popupOption.text = text;
390
396
  return this.setDOMContent(window.document.createTextNode(text));
391
397
  }
398
+ }, {
399
+ key: "setTitle",
400
+ value: function setTitle(title) {
401
+ this.show();
402
+
403
+ if (title) {
404
+ if (!this.contentTitle) {
405
+ this.contentTitle = _l7Utils.DOM.create('div', 'l7-popup-content__title');
406
+
407
+ if (this.content.firstChild) {
408
+ this.content.insertBefore(this.contentTitle, this.content.firstChild);
409
+ } else {
410
+ this.content.append(this.contentTitle);
411
+ }
412
+ }
413
+
414
+ _l7Utils.DOM.clearChildren(this.contentTitle);
415
+
416
+ _l7Utils.DOM.appendElementType(this.contentTitle, title);
417
+ } else if (this.contentTitle) {
418
+ _l7Utils.DOM.remove(this.contentTitle);
419
+
420
+ this.contentTitle = undefined;
421
+ }
422
+ }
392
423
  /**
393
424
  * 将地图自动平移到气泡位置
394
425
  */
@@ -421,6 +452,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
421
452
  value: function setLnglat(lngLat) {
422
453
  var _this2 = this;
423
454
 
455
+ this.show();
424
456
  this.lngLat = lngLat;
425
457
 
426
458
  if (Array.isArray(lngLat)) {
@@ -494,14 +526,17 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
494
526
  }
495
527
  /**
496
528
  * 设置 Popup 内容 HTML
497
- * @param htmlNode
529
+ * @param element
498
530
  */
499
531
 
500
532
  }, {
501
533
  key: "setDOMContent",
502
- value: function setDOMContent(htmlNode) {
534
+ value: function setDOMContent(element) {
535
+ this.show();
503
536
  this.createContent();
504
- this.contentPanel.appendChild(htmlNode);
537
+
538
+ _l7Utils.DOM.appendElementType(this.contentPanel, element);
539
+
505
540
  this.update();
506
541
  return this;
507
542
  }
@@ -565,17 +600,9 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
565
600
  _l7Utils.DOM.remove(this.content);
566
601
  }
567
602
 
603
+ this.contentTitle = undefined;
568
604
  this.content = _l7Utils.DOM.create('div', 'l7-popup-content', this.container);
569
605
 
570
- if (this.popupOption.title) {
571
- var _this$contentTitle;
572
-
573
- this.contentTitle = _l7Utils.DOM.create('div', 'l7-popup-content__title', this.content);
574
- (_this$contentTitle = this.contentTitle) === null || _this$contentTitle === void 0 ? void 0 : _this$contentTitle.append(this.getPopupHTMLFragment(this.popupOption.title));
575
- } else {
576
- this.contentTitle = undefined;
577
- }
578
-
579
606
  if (this.popupOption.closeButton) {
580
607
  var closeButton = (0, _icon.createL7Icon)('l7-icon-guanbi');
581
608
 
@@ -631,39 +658,6 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
631
658
  return key in option;
632
659
  });
633
660
  }
634
- /**
635
- * 根据参数 HTML 片段返回对应的 Fragment
636
- * @param html
637
- * @protected
638
- */
639
-
640
- }, {
641
- key: "getPopupHTMLFragment",
642
- value: function getPopupHTMLFragment(html) {
643
- var frag = window.document.createDocumentFragment();
644
- var temp = window.document.createElement('body');
645
- var child;
646
-
647
- if (typeof html === 'string') {
648
- temp.innerHTML = html;
649
- } else if (Array.isArray(html)) {
650
- temp.append.apply(temp, (0, _toConsumableArray2.default)(html));
651
- } else if (html instanceof HTMLElement) {
652
- temp.append(html);
653
- }
654
-
655
- while (true) {
656
- child = temp.firstChild;
657
-
658
- if (!child) {
659
- break;
660
- }
661
-
662
- frag.appendChild(child);
663
- }
664
-
665
- return frag;
666
- }
667
661
  }]);
668
662
  return Popup;
669
663
  }(_eventemitter.EventEmitter);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.11.1",
3
+ "version": "2.11.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -26,8 +26,8 @@
26
26
  "author": "lzxue",
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
- "@antv/l7-core": "2.11.1",
30
- "@antv/l7-utils": "2.11.1",
29
+ "@antv/l7-core": "2.11.3",
30
+ "@antv/l7-utils": "2.11.3",
31
31
  "@babel/runtime": "^7.7.7",
32
32
  "eventemitter3": "^4.0.0",
33
33
  "inversify": "^5.0.1",
@@ -36,11 +36,11 @@
36
36
  "supercluster": "^7.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@antv/l7-test-utils": "2.11.1",
39
+ "@antv/l7-test-utils": "2.11.3",
40
40
  "gcoord": "^0.3.2",
41
41
  "less": "^4.1.3"
42
42
  },
43
- "gitHead": "e86da32e1999fdc36668de531d16ab14bce56279",
43
+ "gitHead": "73291add563699ecf90ea9c39abbc5a5a5cecc2c",
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  }