mirror of https://gitee.com/antv-l7/antv-l7
fix: 修复地图销毁后,更新 LayerPopup 配置报错问题 (#1480)
* fix: 修复通过 click 方式创建 Popup 同时触发 closeOnClick 问题 * feat: 修复地图销毁之后,调用 LayerPopup 方法报错问题 Co-authored-by: yanxiong <oujinhui.ojh@antgroup.com>
This commit is contained in:
parent
d060794a19
commit
d6ee3cd5cf
|
@ -387,11 +387,14 @@ export default class Popup<O extends IPopupOption = IPopupOption>
|
|||
* @protected
|
||||
*/
|
||||
protected updateCloseOnClick(onlyClear?: boolean) {
|
||||
this.mapsService.off('click', this.onCloseButtonClick);
|
||||
if (this.popupOption.closeOnClick && !onlyClear) {
|
||||
requestAnimationFrame(() => {
|
||||
this.mapsService.on('click', this.onCloseButtonClick);
|
||||
});
|
||||
const mapsService = this.mapsService;
|
||||
if (mapsService) {
|
||||
this.mapsService.off('click', this.onCloseButtonClick);
|
||||
if (this.popupOption.closeOnClick && !onlyClear) {
|
||||
requestAnimationFrame(() => {
|
||||
this.mapsService.on('click', this.onCloseButtonClick);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,12 +408,14 @@ export default class Popup<O extends IPopupOption = IPopupOption>
|
|||
}
|
||||
|
||||
protected updateFollowCursor(onlyClear?: boolean) {
|
||||
const container = this.mapsService.getContainer()!;
|
||||
container.removeEventListener('mousemove', this.onMouseMove);
|
||||
if (this.popupOption.followCursor && !onlyClear) {
|
||||
requestAnimationFrame(() => {
|
||||
container.addEventListener('mousemove', this.onMouseMove);
|
||||
});
|
||||
const container = this.mapsService?.getContainer();
|
||||
if (container) {
|
||||
container.removeEventListener('mousemove', this.onMouseMove);
|
||||
if (this.popupOption.followCursor && !onlyClear) {
|
||||
requestAnimationFrame(() => {
|
||||
container.addEventListener('mousemove', this.onMouseMove);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue