Improve code and its formatting

This commit is contained in:
Maximilian Krög
2021-10-19 22:07:33 +02:00
parent f2f9f68840
commit 5149224354
4 changed files with 37 additions and 53 deletions
+17 -2
View File
@@ -3,6 +3,7 @@
*/
import Control from './Control.js';
import EventType from '../events/EventType.js';
import MapProperty from '../MapProperty.js';
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_UNSUPPORTED} from '../css.js';
import {listen, unlistenByKey} from '../events.js';
import {replaceNode} from '../dom.js';
@@ -187,6 +188,11 @@ class FullScreen extends Control {
* @type {HTMLElement|string|undefined}
*/
this.source_ = options.source;
/**
* @private
*/
this.boundHandleMapTargetChange_ = this.handleMapTargetChange_.bind(this);
}
/**
@@ -271,6 +277,14 @@ class FullScreen extends Control {
* @api
*/
setMap(map) {
const oldMap = this.getMap();
if (oldMap) {
oldMap.removeChangeListener(
MapProperty.TARGET,
this.boundHandleMapTargetChange_
);
}
super.setMap(map);
this.handleMapTargetChange_();
@@ -283,8 +297,9 @@ class FullScreen extends Control {
}
this.setClassName_(this.button_, isFullScreen(doc));
this.listenerKeys.push(
listen(map, 'change:target', this.handleMapTargetChange_, this)
map.addChangeListener(
MapProperty.TARGET,
this.boundHandleMapTargetChange_
);
}
}