直接上代码
var BaseEvent = function () {
this.handles = {}
this.cached = []
}
BaseEvent.prototype.on = function (eventName, callback) {
if (typeof callback !== "function") return;
if (!this.handles[eventName]) {
this.handles[eventName] = [];
}
this.handles[eventName].push(callback);
if (this.cached[eventName] instanceof Array) {
//说明有缓存的 可以执行
callback.apply(null, this.cached[eventName]);
}
}
BaseEvent.prototype.emit = function () {
if (this.handles[arguments[0]] instanceof Array) {
for (let i = 0; i < this.handles[arguments[0]].length; i++) {
this.handles[arguments[0]][i](arguments[1]);
}
}
//默认缓存
this.cached[arguments[0]] = Array.prototype.slice.call(arguments, 1);
}
var CesiumPopup = (function () {
var _panelContainer = null
var _contentContainer = null
var _closeBtn = null
var _renderListener = null
var _vie