Use extends and super for control/ZoomSlider
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/control/ZoomSlider
|
* @module ol/control/ZoomSlider
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../util.js';
|
|
||||||
import ViewHint from '../ViewHint.js';
|
import ViewHint from '../ViewHint.js';
|
||||||
import Control from '../control/Control.js';
|
import Control from '../control/Control.js';
|
||||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||||
@@ -43,15 +42,19 @@ const Direction = {
|
|||||||
* map.addControl(new ZoomSlider());
|
* map.addControl(new ZoomSlider());
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {module:ol/control/Control}
|
|
||||||
* @param {module:ol/control/ZoomSlider~Options=} opt_options Zoom slider options.
|
* @param {module:ol/control/ZoomSlider~Options=} opt_options Zoom slider options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class ZoomSlider {
|
class ZoomSlider extends Control {
|
||||||
constructor(opt_options) {
|
constructor(opt_options) {
|
||||||
|
|
||||||
const options = opt_options ? opt_options : {};
|
const options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
|
super({
|
||||||
|
element: document.createElement('div'),
|
||||||
|
render: options.render || render
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will hold the current resolution of the view.
|
* Will hold the current resolution of the view.
|
||||||
*
|
*
|
||||||
@@ -124,7 +127,7 @@ class ZoomSlider {
|
|||||||
const thumbElement = document.createElement('button');
|
const thumbElement = document.createElement('button');
|
||||||
thumbElement.setAttribute('type', 'button');
|
thumbElement.setAttribute('type', 'button');
|
||||||
thumbElement.className = className + '-thumb ' + CLASS_UNSELECTABLE;
|
thumbElement.className = className + '-thumb ' + CLASS_UNSELECTABLE;
|
||||||
const containerElement = document.createElement('div');
|
const containerElement = this.element;
|
||||||
containerElement.className = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
containerElement.className = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||||
containerElement.appendChild(thumbElement);
|
containerElement.appendChild(thumbElement);
|
||||||
/**
|
/**
|
||||||
@@ -142,11 +145,6 @@ class ZoomSlider {
|
|||||||
|
|
||||||
listen(containerElement, EventType.CLICK, this.handleContainerClick_, this);
|
listen(containerElement, EventType.CLICK, this.handleContainerClick_, this);
|
||||||
listen(thumbElement, EventType.CLICK, stopPropagation);
|
listen(thumbElement, EventType.CLICK, stopPropagation);
|
||||||
|
|
||||||
Control.call(this, {
|
|
||||||
element: containerElement,
|
|
||||||
render: options.render || render
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -154,14 +152,14 @@ class ZoomSlider {
|
|||||||
*/
|
*/
|
||||||
disposeInternal() {
|
disposeInternal() {
|
||||||
this.dragger_.dispose();
|
this.dragger_.dispose();
|
||||||
Control.prototype.disposeInternal.call(this);
|
super.disposeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
setMap(map) {
|
setMap(map) {
|
||||||
Control.prototype.setMap.call(this, map);
|
super.setMap(map);
|
||||||
if (map) {
|
if (map) {
|
||||||
map.render();
|
map.render();
|
||||||
}
|
}
|
||||||
@@ -341,8 +339,6 @@ class ZoomSlider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(ZoomSlider, Control);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the zoomslider element.
|
* Update the zoomslider element.
|
||||||
|
|||||||
Reference in New Issue
Block a user