Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
* @module ol/interaction/KeyboardZoom
|
||||
*/
|
||||
import EventType from '../events/EventType.js';
|
||||
import {targetNotEditable} from '../events/condition.js';
|
||||
import Interaction, {zoomByDelta} from './Interaction.js';
|
||||
|
||||
import {targetNotEditable} from '../events/condition.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
@@ -16,7 +15,6 @@ import Interaction, {zoomByDelta} from './Interaction.js';
|
||||
* @property {number} [delta=1] The zoom level delta on each key press.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Allows the user to zoom the map using keyboard + and -.
|
||||
@@ -35,9 +33,8 @@ class KeyboardZoom extends Interaction {
|
||||
* @param {Options=} opt_options Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
|
||||
super({
|
||||
handleEvent: handleEvent
|
||||
handleEvent: handleEvent,
|
||||
});
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
@@ -59,12 +56,9 @@ class KeyboardZoom extends Interaction {
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = options.duration !== undefined ? options.duration : 100;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the {@link module:ol/MapBrowserEvent map browser event} if it was a
|
||||
* `KeyEvent`, and decides whether to zoom in or out (depending on whether the
|
||||
@@ -75,14 +69,18 @@ class KeyboardZoom extends Interaction {
|
||||
*/
|
||||
function handleEvent(mapBrowserEvent) {
|
||||
let stopEvent = false;
|
||||
if (mapBrowserEvent.type == EventType.KEYDOWN ||
|
||||
mapBrowserEvent.type == EventType.KEYPRESS) {
|
||||
if (
|
||||
mapBrowserEvent.type == EventType.KEYDOWN ||
|
||||
mapBrowserEvent.type == EventType.KEYPRESS
|
||||
) {
|
||||
const keyEvent = /** @type {KeyboardEvent} */ (mapBrowserEvent.originalEvent);
|
||||
const charCode = keyEvent.charCode;
|
||||
if (this.condition_(mapBrowserEvent) &&
|
||||
(charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0))) {
|
||||
if (
|
||||
this.condition_(mapBrowserEvent) &&
|
||||
(charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0))
|
||||
) {
|
||||
const map = mapBrowserEvent.map;
|
||||
const delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||
const delta = charCode == '+'.charCodeAt(0) ? this.delta_ : -this.delta_;
|
||||
const view = map.getView();
|
||||
zoomByDelta(view, delta, undefined, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user