Use extends and super for control/Rotate
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/control/Rotate
|
* @module ol/control/Rotate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Control from '../control/Control.js';
|
import Control from '../control/Control.js';
|
||||||
import {CLASS_CONTROL, CLASS_HIDDEN, CLASS_UNSELECTABLE} from '../css.js';
|
import {CLASS_CONTROL, CLASS_HIDDEN, CLASS_UNSELECTABLE} from '../css.js';
|
||||||
import {easeOut} from '../easing.js';
|
import {easeOut} from '../easing.js';
|
||||||
import {listen} from '../events.js';
|
import {listen} from '../events.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import {inherits} from '../util.js';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,15 +32,20 @@ import {inherits} from '../util.js';
|
|||||||
* selector is added to the button when the rotation is 0.
|
* selector is added to the button when the rotation is 0.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {module:ol/control/Control}
|
|
||||||
* @param {module:ol/control/Rotate~Options=} opt_options Rotate options.
|
* @param {module:ol/control/Rotate~Options=} opt_options Rotate options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Rotate {
|
class Rotate 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,
|
||||||
|
target: options.target
|
||||||
|
});
|
||||||
|
|
||||||
const className = options.className !== undefined ? options.className : 'ol-rotate';
|
const className = options.className !== undefined ? options.className : 'ol-rotate';
|
||||||
|
|
||||||
const label = options.label !== undefined ? options.label : '\u21E7';
|
const label = options.label !== undefined ? options.label : '\u21E7';
|
||||||
@@ -70,22 +73,15 @@ class Rotate {
|
|||||||
button.title = tipLabel;
|
button.title = tipLabel;
|
||||||
button.appendChild(this.label_);
|
button.appendChild(this.label_);
|
||||||
|
|
||||||
listen(button, EventType.CLICK,
|
listen(button, EventType.CLICK, this.handleClick_, this);
|
||||||
Rotate.prototype.handleClick_, this);
|
|
||||||
|
|
||||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||||
const element = document.createElement('div');
|
const element = this.element;
|
||||||
element.className = cssClasses;
|
element.className = cssClasses;
|
||||||
element.appendChild(button);
|
element.appendChild(button);
|
||||||
|
|
||||||
this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
|
this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
|
||||||
|
|
||||||
Control.call(this, {
|
|
||||||
element: element,
|
|
||||||
render: options.render || render,
|
|
||||||
target: options.target
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
@@ -148,8 +144,6 @@ class Rotate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(Rotate, Control);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the rotate control element.
|
* Update the rotate control element.
|
||||||
|
|||||||
Reference in New Issue
Block a user