Fix types for events
This commit is contained in:
@@ -7,25 +7,26 @@ 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} EVENT
|
||||
*/
|
||||
class MapBrowserEvent extends MapEvent {
|
||||
/**
|
||||
* @param {string} type Event type.
|
||||
* @param {import("./PluggableMap.js").default} map Map.
|
||||
* @param {PointerEvent} browserEvent Browser event.
|
||||
* @param {EVENT} originalEvent Original event.
|
||||
* @param {boolean=} opt_dragging Is the map currently being dragged?
|
||||
* @param {?import("./PluggableMap.js").FrameState=} opt_frameState Frame state.
|
||||
*/
|
||||
constructor(type, map, browserEvent, opt_dragging, opt_frameState) {
|
||||
constructor(type, map, originalEvent, opt_dragging, opt_frameState) {
|
||||
super(type, map, opt_frameState);
|
||||
|
||||
/**
|
||||
* The original browser event.
|
||||
* @const
|
||||
* @type {PointerEvent}
|
||||
* @type {EVENT}
|
||||
* @api
|
||||
*/
|
||||
this.originalEvent = browserEvent;
|
||||
this.originalEvent = originalEvent;
|
||||
|
||||
/**
|
||||
* The map pixel relative to the viewport corresponding to the original browser event.
|
||||
@@ -50,7 +51,7 @@ class MapBrowserEvent extends MapEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* The map pixel relative to the viewport corresponding to the original browser event.
|
||||
* The map pixel relative to the viewport corresponding to the original event.
|
||||
* @type {import("./pixel.js").Pixel}
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -704,7 +704,7 @@ class PluggableMap extends BaseObject {
|
||||
|
||||
/**
|
||||
* Returns the coordinate in user projection for a browser event.
|
||||
* @param {Event} event Event.
|
||||
* @param {MouseEvent} event Event.
|
||||
* @return {import("./coordinate.js").Coordinate} Coordinate.
|
||||
* @api
|
||||
*/
|
||||
@@ -714,7 +714,7 @@ class PluggableMap extends BaseObject {
|
||||
|
||||
/**
|
||||
* Returns the coordinate in view projection for a browser event.
|
||||
* @param {Event} event Event.
|
||||
* @param {MouseEvent} event Event.
|
||||
* @return {import("./coordinate.js").Coordinate} Coordinate.
|
||||
*/
|
||||
getEventCoordinateInternal(event) {
|
||||
@@ -723,13 +723,14 @@ class PluggableMap extends BaseObject {
|
||||
|
||||
/**
|
||||
* Returns the map pixel position for a browser event relative to the viewport.
|
||||
* @param {Event|TouchEvent} event Event.
|
||||
* @param {UIEvent} event Event.
|
||||
* @return {import("./pixel.js").Pixel} Pixel.
|
||||
* @api
|
||||
*/
|
||||
getEventPixel(event) {
|
||||
const viewportPosition = this.viewport_.getBoundingClientRect();
|
||||
const eventPosition =
|
||||
//FIXME Are we really calling this with a TouchEvent anywhere?
|
||||
'changedTouches' in event
|
||||
? /** @type {TouchEvent} */ (event).changedTouches[0]
|
||||
: /** @type {MouseEvent} */ (event);
|
||||
@@ -998,7 +999,7 @@ class PluggableMap extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} browserEvent Browser event.
|
||||
* @param {UIEvent} browserEvent Browser event.
|
||||
* @param {string=} opt_type Type.
|
||||
*/
|
||||
handleBrowserEvent(browserEvent, opt_type) {
|
||||
|
||||
@@ -148,7 +148,7 @@ class MousePosition extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} event Browser event.
|
||||
* @param {MouseEvent} event Browser event.
|
||||
* @protected
|
||||
*/
|
||||
handleMouseMove(event) {
|
||||
|
||||
@@ -243,7 +243,7 @@ class OverviewMap extends Control {
|
||||
const move = function (event) {
|
||||
const position = /** @type {?} */ (computeDesiredMousePosition(event));
|
||||
const coordinates = ovmap.getEventCoordinateInternal(
|
||||
/** @type {Event} */ (position)
|
||||
/** @type {MouseEvent} */ (position)
|
||||
);
|
||||
|
||||
overlay.setPosition(coordinates);
|
||||
|
||||
Reference in New Issue
Block a user