Skip to content

Commit

Permalink
fix: 小地图设置回调逻辑调整为抛出事件
Browse files Browse the repository at this point in the history
- 删除原有设置关闭时回调的逻辑
- 现在小地图插件在关闭时会抛出事件 `miniMap:close`,可以通过 `lf.on()` 监听该事件来设置小地图关闭时的回调
  • Loading branch information
ChangeSuger authored and boyongjiong committed Jun 19, 2024
1 parent 995c41a commit c1f8ae4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function MiniMapExtension() {
},
})

;(lf.extension.miniMap as MiniMap).setCloseCallback(() => {
lf.on('miniMap:close', () => {
setVisible(false)
})

Expand Down
16 changes: 1 addition & 15 deletions packages/extension/src/components/mini-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export namespace MiniMap {
}

type Bounds = Record<'left' | 'top' | 'bottom' | 'right', number>
type CallbackFunction = () => any

export class MiniMap {
static pluginName = 'miniMap'
Expand Down Expand Up @@ -173,10 +172,6 @@ export class MiniMap {
* 小地图标题栏的文本内容
*/
private headerTitle = '导航'
/**
* 关闭按钮的回调
*/
private closeCallBack?: CallbackFunction
/**
* 小地图的logicFlow实例需要禁用的插件
*/
Expand Down Expand Up @@ -234,9 +229,7 @@ export class MiniMap {
public hide = () => {
if (this.isShow) {
this.removeMiniMap()
if (this.closeCallBack) {
this.closeCallBack()
}
this.lf.emit('miniMap:close', {})
}
this.isShow = false
}
Expand Down Expand Up @@ -301,13 +294,6 @@ export class MiniMap {
this.setView()
}
}
/**
* 设置关闭小地图时的回调函数,使用 `hide` 方法或通过 CloseIcon 关闭小地图时均会触发该回调函数
* @param callback 回调函数
*/
public setCloseCallback = (callback: CallbackFunction) => {
this.closeCallBack = callback
}

/**
* 初始化小地图的配置
Expand Down

0 comments on commit c1f8ae4

Please sign in to comment.