Get rid of MapBrowserPointerEvent

This commit is contained in:
Andreas Hocevar
2020-05-10 16:54:34 +02:00
parent f16602d07b
commit 33ce206bab
24 changed files with 97 additions and 142 deletions

View File

@@ -7,10 +7,10 @@ import {getValues} from '../obj.js';
/**
* @typedef {Object} Options
* @property {function(import("../MapBrowserPointerEvent.js").default):boolean} [handleDownEvent]
* @property {function(import("../MapBrowserEvent.js").default):boolean} [handleDownEvent]
* Function handling "down" events. If the function returns `true` then a drag
* sequence is started.
* @property {function(import("../MapBrowserPointerEvent.js").default)} [handleDragEvent]
* @property {function(import("../MapBrowserEvent.js").default)} [handleDragEvent]
* Function handling "drag" events. This function is called on "move" events
* during a drag sequence.
* @property {function(import("../MapBrowserEvent.js").default):boolean} [handleEvent]
@@ -18,13 +18,13 @@ import {getValues} from '../obj.js';
* dispatched to the map. The function may return `false` to prevent the
* propagation of the event to other interactions in the map's interactions
* chain.
* @property {function(import("../MapBrowserPointerEvent.js").default)} [handleMoveEvent]
* @property {function(import("../MapBrowserEvent.js").default)} [handleMoveEvent]
* Function handling "move" events. This function is called on "move" events.
* This functions is also called during a drag sequence, so during a drag
* sequence both the `handleDragEvent` function and this function are called.
* If `handleDownEvent` is defined and it returns true this function will not
* be called during a drag sequence.
* @property {function(import("../MapBrowserPointerEvent.js").default):boolean} [handleUpEvent]
* @property {function(import("../MapBrowserEvent.js").default):boolean} [handleUpEvent]
* Function handling "up" events. If the function returns `false` then the
* current drag sequence is stopped.
* @property {function(boolean):boolean} [stopDown]
@@ -105,7 +105,7 @@ class PointerInteraction extends Interaction {
/**
* Handle pointer down events.
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
* @return {boolean} If the event was consumed.
* @protected
*/
@@ -115,7 +115,7 @@ class PointerInteraction extends Interaction {
/**
* Handle pointer drag events.
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
* @protected
*/
handleDragEvent(mapBrowserEvent) {}
@@ -124,12 +124,12 @@ class PointerInteraction extends Interaction {
* Handles the {@link module:ol/MapBrowserEvent map browser event} and may call into
* other functions, if event sequences like e.g. 'drag' or 'down-up' etc. are
* detected.
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Map browser event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @api
*/
handleEvent(mapBrowserEvent) {
if (!mapBrowserEvent.pointerEvent) {
if (!mapBrowserEvent.originalEvent) {
return true;
}
@@ -159,14 +159,14 @@ class PointerInteraction extends Interaction {
/**
* Handle pointer move events.
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
* @protected
*/
handleMoveEvent(mapBrowserEvent) {}
/**
* Handle pointer up events.
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
* @return {boolean} If the event was consumed.
* @protected
*/
@@ -185,12 +185,12 @@ class PointerInteraction extends Interaction {
}
/**
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
* @private
*/
updateTrackedPointers_(mapBrowserEvent) {
if (isPointerDraggingEvent(mapBrowserEvent)) {
const event = mapBrowserEvent.pointerEvent;
const event = mapBrowserEvent.originalEvent;
const id = event.pointerId.toString();
if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
@@ -222,7 +222,7 @@ export function centroid(pointerEvents) {
}
/**
* @param {import("../MapBrowserPointerEvent.js").default} mapBrowserEvent Event.
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
* @return {boolean} Whether the event is a pointerdown, pointerdrag
* or pointerup event.
*/