Skip to content

Commit

Permalink
infoBox添加隐藏关闭图标以及关闭图标点击的事件配置
Browse files Browse the repository at this point in the history
  • Loading branch information
lanjian committed Aug 7, 2021
1 parent 7b2abf7 commit f5c22ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 16 additions & 4 deletions InfoBox/src/InfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ var INFOBOX_AT_TOP = 1, INFOBOX_AT_RIGHT = 2, INFOBOX_AT_BOTTOM = 3, INFOBOX_AT_
this._opts.offset = opts.offset || new BMapGL.Size(0,0);
this._opts.boxClass = opts.boxClass || "infoBox";
this._opts.boxStyle = opts.boxStyle || {};
this._opts.closeIconHide = opts.closeIconHide || false;
this._opts.closeIconClickType = opts.closeIconClickType || 0; // 0 关闭close(销毁div) 1 隐藏hide(display:none)
this._opts.closeIconMargin = opts.closeIconMargin || "2px";
this._opts.closeIconUrl = opts.closeIconUrl || "close.png";
this._opts.enableAutoPan = opts.enableAutoPan ? true : false;
Expand Down Expand Up @@ -503,7 +505,11 @@ var INFOBOX_AT_TOP = 1, INFOBOX_AT_RIGHT = 2, INFOBOX_AT_BOTTOM = 3, INFOBOX_AT_
if(!this._div){
return;
}
var closeHtml = this._getCloseIcon();
var closeHtml = ''
//是否配置显示close
if (!this._opts.closeIconHide) {
closeHtml = this._getCloseIcon();
}
//string类型的content
if(typeof content.nodeType === "undefined"){
this._div.innerHTML = closeHtml + content;
Expand All @@ -513,8 +519,9 @@ var INFOBOX_AT_TOP = 1, INFOBOX_AT_RIGHT = 2, INFOBOX_AT_BOTTOM = 3, INFOBOX_AT_
}
this._content = content;
//添加click关闭infobox事件
this._addEventToClose();

if (!this._opts.closeIconHide) {
this._addEventToClose();
}
},
/**
* 调整infobox的position
Expand Down Expand Up @@ -578,7 +585,12 @@ var INFOBOX_AT_TOP = 1, INFOBOX_AT_RIGHT = 2, INFOBOX_AT_BOTTOM = 3, INFOBOX_AT_
_closeHandler: function(){
var me = this;
return function(e){
me.close();
// 点击关闭按钮的事件 0 关闭 1 隐藏
if (me._opts.closeIconClickType === 0) {
me.close();
} else {
me.hide();
}
}
},
/**
Expand Down
Loading

0 comments on commit f5c22ac

Please sign in to comment.