Set pointerEvents style programmatically instead of relying on ol.css

This commit is contained in:
Andreas Hocevar
2020-04-16 17:34:40 +02:00
parent 12043e147c
commit 7f6258dd0d
14 changed files with 27 additions and 22 deletions

View File

@@ -48,10 +48,10 @@ class Attribution extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
render: options.render,
target: options.target,
});
this.createElement();
/**
* @private

View File

@@ -83,6 +83,17 @@ class Control extends BaseObject {
}
}
/**
* Creates the element for this control and sets it on the instance.
* @return {HTMLDivElement} Element for this control.
*/
createElement() {
const element = document.createElement('div');
element.style.pointerEvents = 'auto';
this.element = element;
return element;
}
/**
* Clean up.
*/

View File

@@ -72,9 +72,9 @@ class FullScreen extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
target: options.target,
});
this.createElement();
/**
* @private

View File

@@ -60,16 +60,15 @@ class MousePosition extends Control {
constructor(opt_options) {
const options = opt_options ? opt_options : {};
const element = document.createElement('div');
element.className =
options.className !== undefined ? options.className : 'ol-mouse-position';
super({
element: element,
render: options.render,
target: options.target,
});
const element = this.createElement();
element.className =
options.className !== undefined ? options.className : 'ol-mouse-position';
this.addEventListener(
getChangeEventType(PROJECTION),
this.handleProjectionChanged_

View File

@@ -80,10 +80,10 @@ class OverviewMap extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
render: options.render,
target: options.target,
});
this.createElement();
/**
* @private

View File

@@ -38,10 +38,10 @@ class Rotate extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
render: options.render,
target: options.target,
});
this.createElement();
const className =
options.className !== undefined ? options.className : 'ol-rotate';

View File

@@ -86,10 +86,10 @@ class ScaleLine extends Control {
: 'ol-scale-line';
super({
element: document.createElement('div'),
render: options.render,
target: options.target,
});
this.createElement();
/**
* @private

View File

@@ -37,9 +37,9 @@ class Zoom extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
target: options.target,
});
this.createElement();
const className =
options.className !== undefined ? options.className : 'ol-zoom';

View File

@@ -48,9 +48,9 @@ class ZoomSlider extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
render: options.render,
});
this.createElement();
/**
* @type {!Array.<import("../events.js").EventsKey>}

View File

@@ -33,9 +33,9 @@ class ZoomToExtent extends Control {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
target: options.target,
});
this.createElement();
/**
* @type {?import("../extent.js").Extent}