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,6 +387,8 @@ export default class Popup<O extends IPopupOption = IPopupOption>
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
protected updateCloseOnClick(onlyClear?: boolean) {
|
protected updateCloseOnClick(onlyClear?: boolean) {
|
||||||
|
const mapsService = this.mapsService;
|
||||||
|
if (mapsService) {
|
||||||
this.mapsService.off('click', this.onCloseButtonClick);
|
this.mapsService.off('click', this.onCloseButtonClick);
|
||||||
if (this.popupOption.closeOnClick && !onlyClear) {
|
if (this.popupOption.closeOnClick && !onlyClear) {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
@ -394,6 +396,7 @@ export default class Popup<O extends IPopupOption = IPopupOption>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected updateCloseOnEsc(onlyClear?: boolean) {
|
protected updateCloseOnEsc(onlyClear?: boolean) {
|
||||||
window.removeEventListener('keydown', this.onKeyDown);
|
window.removeEventListener('keydown', this.onKeyDown);
|
||||||
|
@ -405,7 +408,8 @@ export default class Popup<O extends IPopupOption = IPopupOption>
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updateFollowCursor(onlyClear?: boolean) {
|
protected updateFollowCursor(onlyClear?: boolean) {
|
||||||
const container = this.mapsService.getContainer()!;
|
const container = this.mapsService?.getContainer();
|
||||||
|
if (container) {
|
||||||
container.removeEventListener('mousemove', this.onMouseMove);
|
container.removeEventListener('mousemove', this.onMouseMove);
|
||||||
if (this.popupOption.followCursor && !onlyClear) {
|
if (this.popupOption.followCursor && !onlyClear) {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
@ -413,6 +417,7 @@ export default class Popup<O extends IPopupOption = IPopupOption>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected onKeyDown = (e: KeyboardEvent) => {
|
protected onKeyDown = (e: KeyboardEvent) => {
|
||||||
if (e.keyCode === 27) {
|
if (e.keyCode === 27) {
|
||||||
|
|
Loading…
Reference in New Issue