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:
@@ -1,11 +1,10 @@
|
||||
/**
|
||||
* @module ol/interaction/Pointer
|
||||
*/
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import Interaction from './Interaction.js';
|
||||
import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import {getValues} from '../obj.js';
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {function(import("../MapBrowserPointerEvent.js").default):boolean} [handleDownEvent]
|
||||
@@ -33,7 +32,6 @@ import {getValues} from '../obj.js';
|
||||
* stopped?
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Base class that calls user-defined functions on `down`, `move` and `up`
|
||||
@@ -50,10 +48,11 @@ class PointerInteraction extends Interaction {
|
||||
* @param {Options=} opt_options Options.
|
||||
*/
|
||||
constructor(opt_options) {
|
||||
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
super(/** @type {import("./Interaction.js").InteractionOptions} */ (options));
|
||||
super(
|
||||
/** @type {import("./Interaction.js").InteractionOptions} */ (options)
|
||||
);
|
||||
|
||||
if (options.handleDownEvent) {
|
||||
this.handleDownEvent = options.handleDownEvent;
|
||||
@@ -92,7 +91,6 @@ class PointerInteraction extends Interaction {
|
||||
* @protected
|
||||
*/
|
||||
this.targetPointers = [];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +140,8 @@ class PointerInteraction extends Interaction {
|
||||
this.handleDragEvent(mapBrowserEvent);
|
||||
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
|
||||
const handledUp = this.handleUpEvent(mapBrowserEvent);
|
||||
this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0;
|
||||
this.handlingDownUpSequence =
|
||||
handledUp && this.targetPointers.length > 0;
|
||||
}
|
||||
} else {
|
||||
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDOWN) {
|
||||
@@ -194,8 +193,7 @@ class PointerInteraction extends Interaction {
|
||||
const id = event.pointerId.toString();
|
||||
if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
|
||||
delete this.trackedPointers_[id];
|
||||
} else if (mapBrowserEvent.type ==
|
||||
MapBrowserEventType.POINTERDOWN) {
|
||||
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERDOWN) {
|
||||
this.trackedPointers_[id] = event;
|
||||
} else if (id in this.trackedPointers_) {
|
||||
// update only when there was a pointerdown event for this pointer
|
||||
@@ -204,10 +202,8 @@ class PointerInteraction extends Interaction {
|
||||
this.targetPointers = getValues(this.trackedPointers_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array<PointerEvent>} pointerEvents List of events.
|
||||
* @return {import("../pixel.js").Pixel} Centroid pixel.
|
||||
@@ -223,7 +219,6 @@ export function centroid(pointerEvents) {
|
||||
return [clientX / length, clientY / length];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
|
||||
* @return {boolean} Whether the event is a pointerdown, pointerdrag
|
||||
@@ -231,10 +226,11 @@ export function centroid(pointerEvents) {
|
||||
*/
|
||||
function isPointerDraggingEvent(mapBrowserEvent) {
|
||||
const type = mapBrowserEvent.type;
|
||||
return type === MapBrowserEventType.POINTERDOWN ||
|
||||
return (
|
||||
type === MapBrowserEventType.POINTERDOWN ||
|
||||
type === MapBrowserEventType.POINTERDRAG ||
|
||||
type === MapBrowserEventType.POINTERUP;
|
||||
type === MapBrowserEventType.POINTERUP
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default PointerInteraction;
|
||||
|
||||
Reference in New Issue
Block a user