Memory leak in ol.control.FullScreen
Register and unregister listener in setMap method.
This commit is contained in:
@@ -68,10 +68,6 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
ol.events.listen(button, ol.events.EventType.CLICK,
|
ol.events.listen(button, ol.events.EventType.CLICK,
|
||||||
this.handleClick_, this);
|
this.handleClick_, this);
|
||||||
|
|
||||||
ol.events.listen(goog.global.document,
|
|
||||||
goog.dom.fullscreen.EventType.CHANGE,
|
|
||||||
this.handleFullScreenChange_, this);
|
|
||||||
|
|
||||||
var cssClasses = this.cssClassName_ + ' ' + ol.css.CLASS_UNSELECTABLE +
|
var cssClasses = this.cssClassName_ + ' ' + ol.css.CLASS_UNSELECTABLE +
|
||||||
' ' + ol.css.CLASS_CONTROL + ' ' +
|
' ' + ol.css.CLASS_CONTROL + ' ' +
|
||||||
(!goog.dom.fullscreen.isSupported() ? ol.css.CLASS_UNSUPPORTED : '');
|
(!goog.dom.fullscreen.isSupported() ? ol.css.CLASS_UNSUPPORTED : '');
|
||||||
@@ -153,3 +149,18 @@ ol.control.FullScreen.prototype.handleFullScreenChange_ = function() {
|
|||||||
map.updateSize();
|
map.updateSize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
ol.control.FullScreen.prototype.setMap = function (map) {
|
||||||
|
goog.base(this, 'setMap', map);
|
||||||
|
if (map) {
|
||||||
|
this.listenerKeys.push(
|
||||||
|
ol.events.listen(goog.global.document, goog.dom.fullscreen.EventType.CHANGE,
|
||||||
|
this.handleFullScreenChange_, this);
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user