@antv/l7-component 2.23.1 → 2.23.3-beta.0
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.
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -827
- package/es/interface.d.ts +11 -0
- package/es/marker-layer.d.ts +2 -11
- package/es/marker-layer.js +206 -9
- package/es/marker.d.ts +10 -3
- package/es/marker.js +44 -16
- package/es/popup/layerPopup.d.ts +2 -2
- package/es/popup/layerPopup.js +7 -5
- package/es/popup/popup.d.ts +5 -0
- package/es/popup/popup.js +19 -1
- package/es/utils/eventManager.d.ts +42 -0
- package/es/utils/eventManager.js +84 -0
- package/es/utils/popper.js +8 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -829
- package/lib/interface.d.ts +11 -0
- package/lib/marker-layer.d.ts +2 -11
- package/lib/marker-layer.js +206 -9
- package/lib/marker.d.ts +10 -3
- package/lib/marker.js +44 -16
- package/lib/popup/layerPopup.d.ts +2 -2
- package/lib/popup/layerPopup.js +7 -5
- package/lib/popup/popup.d.ts +5 -0
- package/lib/popup/popup.js +19 -1
- package/lib/utils/eventManager.d.ts +42 -0
- package/lib/utils/eventManager.js +92 -0
- package/lib/utils/popper.js +8 -0
- package/package.json +10 -8
- package/es/css/index.css +0 -781
- package/lib/css/index.css +0 -781
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.EventManager = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
/**
|
|
10
|
+
* 事件管理器,用于统一管理事件绑定和解绑
|
|
11
|
+
* 解决组件销毁时事件未正确清理导致的内存泄漏问题
|
|
12
|
+
*/
|
|
13
|
+
class EventManager {
|
|
14
|
+
constructor() {
|
|
15
|
+
(0, _defineProperty2.default)(this, "bindings", []);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 绑定事件
|
|
19
|
+
* @param target 事件目标对象
|
|
20
|
+
* @param event 事件名称
|
|
21
|
+
* @param handler 事件处理函数
|
|
22
|
+
*/
|
|
23
|
+
on(target, event, handler) {
|
|
24
|
+
this.bindings.push({
|
|
25
|
+
target,
|
|
26
|
+
event,
|
|
27
|
+
handler
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// 根据目标类型选择绑定方式
|
|
31
|
+
if (this.isMapService(target)) {
|
|
32
|
+
target.on(event, handler);
|
|
33
|
+
} else {
|
|
34
|
+
target.addEventListener(event, handler);
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 解绑指定事件
|
|
41
|
+
* @param target 事件目标对象
|
|
42
|
+
* @param event 事件名称
|
|
43
|
+
* @param handler 事件处理函数
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
off(target, event, handler) {
|
|
47
|
+
const index = this.bindings.findIndex(b => b.target === target && b.event === event && b.handler === handler);
|
|
48
|
+
if (index > -1) {
|
|
49
|
+
this.bindings.splice(index, 1);
|
|
50
|
+
if (this.isMapService(target)) {
|
|
51
|
+
target.off(event, handler);
|
|
52
|
+
} else {
|
|
53
|
+
target.removeEventListener(event, handler);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 清除所有绑定的事件
|
|
61
|
+
*/
|
|
62
|
+
clear() {
|
|
63
|
+
this.bindings.forEach(({
|
|
64
|
+
target,
|
|
65
|
+
event,
|
|
66
|
+
handler
|
|
67
|
+
}) => {
|
|
68
|
+
if (this.isMapService(target)) {
|
|
69
|
+
target.off(event, handler);
|
|
70
|
+
} else {
|
|
71
|
+
target.removeEventListener(event, handler);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
this.bindings = [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 获取当前绑定的事件数量
|
|
79
|
+
*/
|
|
80
|
+
size() {
|
|
81
|
+
return this.bindings.length;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 判断目标是否为 MapService
|
|
86
|
+
*/
|
|
87
|
+
isMapService(target) {
|
|
88
|
+
return target && typeof target.on === 'function' && typeof target.off === 'function';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.EventManager = EventManager;
|
|
92
|
+
var _default = exports.default = EventManager;
|
package/lib/utils/popper.js
CHANGED
|
@@ -175,6 +175,14 @@ class Popper extends _eventemitter.EventEmitter {
|
|
|
175
175
|
this.popperDOM.removeEventListener('mousemove', this.onBtnMouseMove);
|
|
176
176
|
this.popperDOM.removeEventListener('mouseleave', this.onBtnMouseLeave);
|
|
177
177
|
_l7Utils.DOM.remove(this.popperDOM);
|
|
178
|
+
|
|
179
|
+
// 从 conflictPopperList 中移除当前实例,防止内存泄漏
|
|
180
|
+
if (this.option.unique) {
|
|
181
|
+
const index = Popper.conflictPopperList.indexOf(this);
|
|
182
|
+
if (index > -1) {
|
|
183
|
+
Popper.conflictPopperList.splice(index, 1);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
178
186
|
}
|
|
179
187
|
resetPopperPosition() {
|
|
180
188
|
const popperStyleObj = {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-component",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.3-beta.0",
|
|
4
4
|
"description": "Component for L7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/orgs/antvis/people",
|
|
7
|
-
"sideEffects":
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"*.css",
|
|
9
|
+
"*.less"
|
|
10
|
+
],
|
|
8
11
|
"main": "lib/index.js",
|
|
9
12
|
"module": "es/index.js",
|
|
10
13
|
"types": "es/index.d.ts",
|
|
@@ -16,13 +19,13 @@
|
|
|
16
19
|
"@babel/runtime": "^7.7.7",
|
|
17
20
|
"eventemitter3": "^4.0.0",
|
|
18
21
|
"supercluster": "^7.0.0",
|
|
19
|
-
"@antv/l7-core": "2.23.
|
|
20
|
-
"@antv/l7-layers": "2.23.
|
|
21
|
-
"@antv/l7-utils": "2.23.
|
|
22
|
+
"@antv/l7-core": "2.23.3-beta.0",
|
|
23
|
+
"@antv/l7-layers": "2.23.3-beta.0",
|
|
24
|
+
"@antv/l7-utils": "2.23.3-beta.0"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"less": "^4.1.3",
|
|
25
|
-
"@antv/l7-test-utils": "^2.23.
|
|
28
|
+
"@antv/l7-test-utils": "^2.23.3-beta.0"
|
|
26
29
|
},
|
|
27
30
|
"publishConfig": {
|
|
28
31
|
"access": "public",
|
|
@@ -34,7 +37,6 @@
|
|
|
34
37
|
"build": "npm run clean && father build",
|
|
35
38
|
"check-deps": "father doctor",
|
|
36
39
|
"lint": "eslint src __tests__",
|
|
37
|
-
"clean": "rimraf dist es lib"
|
|
38
|
-
"less": "lessc src/css/index.less src/css/index.css"
|
|
40
|
+
"clean": "rimraf dist es lib"
|
|
39
41
|
}
|
|
40
42
|
}
|