Fix singleclick and doubleclick events

This commit is contained in:
Andreas Hocevar
2021-03-25 20:55:40 +01:00
parent ccde59cff9
commit 158f6c7bcd
3 changed files with 9 additions and 18 deletions

View File

@@ -7,7 +7,7 @@ import MapEvent from './MapEvent.js';
* @classdesc
* Events emitted as map browser events are instances of this type.
* See {@link module:ol/PluggableMap~PluggableMap} for which events trigger a map browser event.
* @template {UIEvent|import("./MapBrowserEventHandler").PointerEventData} EVENT
* @template {UIEvent} EVENT
*/
class MapBrowserEvent extends MapEvent {
/**

View File

@@ -10,14 +10,6 @@ import Target from './events/Target.js';
import {DEVICE_PIXEL_RATIO, PASSIVE_EVENT_LISTENERS} from './has.js';
import {listen, unlistenByKey} from './events.js';
/**
* @typedef {Object} PointerEventData
* @property {string} type The type of the pointer event.
* @property {number} clientX ClientX.
* @property {number} clientY ClientY.
* @property {EventTarget} target The target of the event.
*/
class MapBrowserEventHandler extends Target {
/**
* @param {import("./PluggableMap.js").default} map The map with the viewport to listen to events on.
@@ -68,7 +60,7 @@ class MapBrowserEventHandler extends Target {
/**
* The most recent "down" type event (or null if none have occurred).
* Set on pointerdown.
* @type {PointerEventData}
* @type {PointerEvent}
* @private
*/
this.down_ = null;
@@ -130,7 +122,7 @@ class MapBrowserEventHandler extends Target {
}
/**
* @param {PointerEventData} pointerEvent Pointer
* @param {PointerEvent} pointerEvent Pointer
* event.
* @private
*/
@@ -252,12 +244,11 @@ class MapBrowserEventHandler extends Target {
);
this.dispatchEvent(newEvent);
this.down_ = {
type: pointerEvent.type,
clientX: pointerEvent.clientX,
clientY: pointerEvent.clientY,
target: pointerEvent.target,
};
this.down_ = new PointerEvent(pointerEvent.type, pointerEvent);
Object.defineProperty(this.down_, 'target', {
writable: false,
value: pointerEvent.target,
});
if (this.dragListenerKeys_.length === 0) {
const doc = this.map_.getOwnerDocument();

View File

@@ -682,7 +682,7 @@ class PluggableMap extends BaseObject {
/**
* Returns the map pixel position for a browser event relative to the viewport.
* @param {UIEvent|import("./MapBrowserEventHandler").PointerEventData} event Event.
* @param {UIEvent} event Event.
* @return {import("./pixel.js").Pixel} Pixel.
* @api
*/