@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,84 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
/**
|
|
3
|
+
* 事件管理器,用于统一管理事件绑定和解绑
|
|
4
|
+
* 解决组件销毁时事件未正确清理导致的内存泄漏问题
|
|
5
|
+
*/
|
|
6
|
+
export class EventManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
_defineProperty(this, "bindings", []);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 绑定事件
|
|
12
|
+
* @param target 事件目标对象
|
|
13
|
+
* @param event 事件名称
|
|
14
|
+
* @param handler 事件处理函数
|
|
15
|
+
*/
|
|
16
|
+
on(target, event, handler) {
|
|
17
|
+
this.bindings.push({
|
|
18
|
+
target,
|
|
19
|
+
event,
|
|
20
|
+
handler
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 根据目标类型选择绑定方式
|
|
24
|
+
if (this.isMapService(target)) {
|
|
25
|
+
target.on(event, handler);
|
|
26
|
+
} else {
|
|
27
|
+
target.addEventListener(event, handler);
|
|
28
|
+
}
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 解绑指定事件
|
|
34
|
+
* @param target 事件目标对象
|
|
35
|
+
* @param event 事件名称
|
|
36
|
+
* @param handler 事件处理函数
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
off(target, event, handler) {
|
|
40
|
+
const index = this.bindings.findIndex(b => b.target === target && b.event === event && b.handler === handler);
|
|
41
|
+
if (index > -1) {
|
|
42
|
+
this.bindings.splice(index, 1);
|
|
43
|
+
if (this.isMapService(target)) {
|
|
44
|
+
target.off(event, handler);
|
|
45
|
+
} else {
|
|
46
|
+
target.removeEventListener(event, handler);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 清除所有绑定的事件
|
|
54
|
+
*/
|
|
55
|
+
clear() {
|
|
56
|
+
this.bindings.forEach(({
|
|
57
|
+
target,
|
|
58
|
+
event,
|
|
59
|
+
handler
|
|
60
|
+
}) => {
|
|
61
|
+
if (this.isMapService(target)) {
|
|
62
|
+
target.off(event, handler);
|
|
63
|
+
} else {
|
|
64
|
+
target.removeEventListener(event, handler);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
this.bindings = [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 获取当前绑定的事件数量
|
|
72
|
+
*/
|
|
73
|
+
size() {
|
|
74
|
+
return this.bindings.length;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 判断目标是否为 MapService
|
|
79
|
+
*/
|
|
80
|
+
isMapService(target) {
|
|
81
|
+
return target && typeof target.on === 'function' && typeof target.off === 'function';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export default EventManager;
|
package/es/utils/popper.js
CHANGED
|
@@ -169,6 +169,14 @@ export class Popper extends EventEmitter {
|
|
|
169
169
|
this.popperDOM.removeEventListener('mousemove', this.onBtnMouseMove);
|
|
170
170
|
this.popperDOM.removeEventListener('mouseleave', this.onBtnMouseLeave);
|
|
171
171
|
DOM.remove(this.popperDOM);
|
|
172
|
+
|
|
173
|
+
// 从 conflictPopperList 中移除当前实例,防止内存泄漏
|
|
174
|
+
if (this.option.unique) {
|
|
175
|
+
const index = Popper.conflictPopperList.indexOf(this);
|
|
176
|
+
if (index > -1) {
|
|
177
|
+
Popper.conflictPopperList.splice(index, 1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
172
180
|
}
|
|
173
181
|
resetPopperPosition() {
|
|
174
182
|
const popperStyleObj = {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Marker from './marker';
|
|
2
2
|
import MarkerLayer from './marker-layer';
|
|
3
3
|
import './assets/iconfont/iconfont.js';
|
|
4
|
-
import './css/index.
|
|
4
|
+
import './css/index.less';
|
|
5
5
|
export * from './control/baseControl';
|
|
6
6
|
export { ExportImage, type IExportImageControlOption } from './control/exportImage';
|
|
7
7
|
export { Fullscreen, type IFullscreenControlOption } from './control/fullscreen';
|