Merge pull request #12143 from ahocevar/fix-singleclick-doubleclick
Fix singleclick and doubleclick events
This commit is contained in:
@@ -7,7 +7,7 @@ import MapEvent from './MapEvent.js';
|
|||||||
* @classdesc
|
* @classdesc
|
||||||
* Events emitted as map browser events are instances of this type.
|
* 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.
|
* 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 {
|
class MapBrowserEvent extends MapEvent {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,14 +10,6 @@ import Target from './events/Target.js';
|
|||||||
import {DEVICE_PIXEL_RATIO, PASSIVE_EVENT_LISTENERS} from './has.js';
|
import {DEVICE_PIXEL_RATIO, PASSIVE_EVENT_LISTENERS} from './has.js';
|
||||||
import {listen, unlistenByKey} from './events.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 {
|
class MapBrowserEventHandler extends Target {
|
||||||
/**
|
/**
|
||||||
* @param {import("./PluggableMap.js").default} map The map with the viewport to listen to events on.
|
* @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).
|
* The most recent "down" type event (or null if none have occurred).
|
||||||
* Set on pointerdown.
|
* Set on pointerdown.
|
||||||
* @type {PointerEventData}
|
* @type {PointerEvent}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.down_ = null;
|
this.down_ = null;
|
||||||
@@ -130,7 +122,7 @@ class MapBrowserEventHandler extends Target {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {PointerEventData} pointerEvent Pointer
|
* @param {PointerEvent} pointerEvent Pointer
|
||||||
* event.
|
* event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -252,12 +244,11 @@ class MapBrowserEventHandler extends Target {
|
|||||||
);
|
);
|
||||||
this.dispatchEvent(newEvent);
|
this.dispatchEvent(newEvent);
|
||||||
|
|
||||||
this.down_ = {
|
this.down_ = new PointerEvent(pointerEvent.type, pointerEvent);
|
||||||
type: pointerEvent.type,
|
Object.defineProperty(this.down_, 'target', {
|
||||||
clientX: pointerEvent.clientX,
|
writable: false,
|
||||||
clientY: pointerEvent.clientY,
|
value: pointerEvent.target,
|
||||||
target: pointerEvent.target,
|
});
|
||||||
};
|
|
||||||
|
|
||||||
if (this.dragListenerKeys_.length === 0) {
|
if (this.dragListenerKeys_.length === 0) {
|
||||||
const doc = this.map_.getOwnerDocument();
|
const doc = this.map_.getOwnerDocument();
|
||||||
|
|||||||
@@ -682,7 +682,7 @@ class PluggableMap extends BaseObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the map pixel position for a browser event relative to the viewport.
|
* 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.
|
* @return {import("./pixel.js").Pixel} Pixel.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user