@antv/l7-component 2.20.1 → 2.20.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.
@@ -13,7 +13,9 @@ import { createL7Icon } from "../utils/icon";
13
13
  import SelectControl from "./baseControl/selectControl";
14
14
  export { LayerSwitch };
15
15
  function isLayerSwitchItem(obj) {
16
- return obj && obj.layer;
16
+ return Object.keys(obj !== null && obj !== void 0 ? obj : {}).every(function (key) {
17
+ return ['layer', 'name', 'img'].includes(key);
18
+ });
17
19
  }
18
20
  var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
19
21
  _inherits(LayerSwitch, _SelectControl);
@@ -102,24 +102,26 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
102
102
  }, {
103
103
  key: "setOptions",
104
104
  value: function setOptions(option) {
105
- var _newOption$items;
106
105
  this.unbindLayerEvent();
107
106
  var newOption = _objectSpread({}, option);
108
- var trigger = option.trigger || this.popupOption.trigger;
109
- if (((_newOption$items = newOption.items) === null || _newOption$items === void 0 ? void 0 : _newOption$items.length) === 0 && trigger === 'hover') {
110
- newOption.followCursor = false;
111
- }
107
+ var trigger = newOption.trigger || this.popupOption.trigger;
108
+ var items = newOption.items || this.popupOption.items;
109
+ var isEmptyItems = (items === null || items === void 0 ? void 0 : items.length) === 0;
110
+ newOption.followCursor = trigger === 'hover' && !isEmptyItems;
112
111
  _get(_getPrototypeOf(LayerPopup.prototype), "setOptions", this).call(this, newOption);
113
112
  this.bindLayerEvent();
113
+ if (isEmptyItems) {
114
+ this.hide();
115
+ }
114
116
  return this;
115
117
  }
116
118
  }, {
117
119
  key: "getDefault",
118
120
  value: function getDefault(option) {
119
- var isClickTrigger = option.trigger === 'click';
121
+ var isHoverTrigger = option.trigger === 'hover';
120
122
  return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(LayerPopup.prototype), "getDefault", this).call(this, option)), {}, {
121
123
  trigger: 'hover',
122
- followCursor: !isClickTrigger,
124
+ followCursor: isHoverTrigger,
123
125
  lngLat: {
124
126
  lng: 0,
125
127
  lat: 0
@@ -19,7 +19,9 @@ var _selectControl = _interopRequireDefault(require("./baseControl/selectControl
19
19
  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); }; }
20
20
  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; } }
21
21
  function isLayerSwitchItem(obj) {
22
- return obj && obj.layer;
22
+ return Object.keys(obj !== null && obj !== void 0 ? obj : {}).every(function (key) {
23
+ return ['layer', 'name', 'img'].includes(key);
24
+ });
23
25
  }
24
26
  var LayerSwitch = exports.default = exports.LayerSwitch = /*#__PURE__*/function (_SelectControl) {
25
27
  (0, _inherits2.default)(LayerSwitch, _SelectControl);
@@ -108,24 +108,26 @@ var LayerPopup = exports.default = exports.LayerPopup = /*#__PURE__*/function (_
108
108
  }, {
109
109
  key: "setOptions",
110
110
  value: function setOptions(option) {
111
- var _newOption$items;
112
111
  this.unbindLayerEvent();
113
112
  var newOption = (0, _objectSpread2.default)({}, option);
114
- var trigger = option.trigger || this.popupOption.trigger;
115
- if (((_newOption$items = newOption.items) === null || _newOption$items === void 0 ? void 0 : _newOption$items.length) === 0 && trigger === 'hover') {
116
- newOption.followCursor = false;
117
- }
113
+ var trigger = newOption.trigger || this.popupOption.trigger;
114
+ var items = newOption.items || this.popupOption.items;
115
+ var isEmptyItems = (items === null || items === void 0 ? void 0 : items.length) === 0;
116
+ newOption.followCursor = trigger === 'hover' && !isEmptyItems;
118
117
  (0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "setOptions", this).call(this, newOption);
119
118
  this.bindLayerEvent();
119
+ if (isEmptyItems) {
120
+ this.hide();
121
+ }
120
122
  return this;
121
123
  }
122
124
  }, {
123
125
  key: "getDefault",
124
126
  value: function getDefault(option) {
125
- var isClickTrigger = option.trigger === 'click';
127
+ var isHoverTrigger = option.trigger === 'hover';
126
128
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "getDefault", this).call(this, option)), {}, {
127
129
  trigger: 'hover',
128
- followCursor: !isClickTrigger,
130
+ followCursor: isHoverTrigger,
129
131
  lngLat: {
130
132
  lng: 0,
131
133
  lat: 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.20.1",
3
+ "version": "2.20.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.20.1",
30
- "@antv/l7-utils": "2.20.1",
29
+ "@antv/l7-core": "2.20.3",
30
+ "@antv/l7-utils": "2.20.3",
31
31
  "@babel/runtime": "^7.7.7",
32
32
  "eventemitter3": "^4.0.0",
33
33
  "inversify": "^5.0.1",
@@ -35,12 +35,12 @@
35
35
  "supercluster": "^7.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@antv/l7-layers": "2.20.1",
39
- "@antv/l7-test-utils": "2.20.1",
38
+ "@antv/l7-layers": "2.20.3",
39
+ "@antv/l7-test-utils": "2.20.3",
40
40
  "gcoord": "^0.3.2",
41
41
  "less": "^4.1.3"
42
42
  },
43
- "gitHead": "9cf19c5a23723463d852a905b8a8230abbe96c72",
43
+ "gitHead": "c9f82837e7f8a6f661bce8dee94e794d3cec89c7",
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  }