Move postrender event listening into base class

This commit is contained in:
Tom Payne
2013-04-05 20:33:50 +02:00
parent da1e5aadd3
commit 06bcab8374
6 changed files with 31 additions and 118 deletions

View File

@@ -5,13 +5,10 @@ goog.provide('ol.control.Attribution');
goog.require('goog.array');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.object');
goog.require('goog.style');
goog.require('ol.Attribution');
goog.require('ol.FrameState');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.TileRange');
goog.require('ol.control.Control');
goog.require('ol.css');
@@ -62,12 +59,6 @@ ol.control.Attribution = function(opt_options) {
*/
this.attributionElementRenderedVisible_ = {};
/**
* @private
* @type {?number}
*/
this.postrenderListenKey_ = null;
};
goog.inherits(ol.control.Attribution, ol.control.Control);
@@ -108,29 +99,13 @@ ol.control.Attribution.prototype.getTileSourceAttributions =
/**
* @param {ol.MapEvent} mapEvent Map event.
* @inheritDoc
*/
ol.control.Attribution.prototype.handleMapPostrender = function(mapEvent) {
this.updateElement_(mapEvent.frameState);
};
/**
* @inheritDoc
*/
ol.control.Attribution.prototype.setMap = function(map) {
if (!goog.isNull(this.postrenderListenKey_)) {
goog.events.unlistenByKey(this.postrenderListenKey_);
this.postrenderListenKey_ = null;
}
goog.base(this, 'setMap', map);
if (!goog.isNull(map)) {
this.postrenderListenKey_ = goog.events.listen(
map, ol.MapEventType.POSTRENDER, this.handleMapPostrender, false, this);
}
};
/**
* @private
* @param {?ol.FrameState} frameState Frame state.