Always dispatch pointermove, but calculate coordinates lazily
This commit is contained in:
@@ -32,16 +32,14 @@ class MapBrowserEvent extends MapEvent {
|
||||
/**
|
||||
* The map pixel relative to the viewport corresponding to the original browser event.
|
||||
* @type {import("./pixel.js").Pixel}
|
||||
* @api
|
||||
*/
|
||||
this.pixel = map.getEventPixel(browserEvent);
|
||||
this.pixel_ = null;
|
||||
|
||||
/**
|
||||
* The coordinate in view projection corresponding to the original browser event.
|
||||
* @type {import("./coordinate.js").Coordinate}
|
||||
* @api
|
||||
*/
|
||||
this.coordinate = map.getCoordinateFromPixel(this.pixel);
|
||||
this.coordinate_ = null;
|
||||
|
||||
/**
|
||||
* Indicates if the map is currently being dragged. Only set for
|
||||
@@ -54,6 +52,36 @@ class MapBrowserEvent extends MapEvent {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The map pixel relative to the viewport corresponding to the original browser event.
|
||||
* @type {import("./pixel.js").Pixel}
|
||||
* @api
|
||||
*/
|
||||
get pixel() {
|
||||
if (!this.pixel_) {
|
||||
this.pixel_ = this.map.getEventPixel(this.originalEvent);
|
||||
}
|
||||
return this.pixel_;
|
||||
}
|
||||
set pixel(pixel) {
|
||||
this.pixel_ = pixel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The coordinate in view projection corresponding to the original browser event.
|
||||
* @type {import("./coordinate.js").Coordinate}
|
||||
* @api
|
||||
*/
|
||||
get coordinate() {
|
||||
if (!this.coordinate_) {
|
||||
this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel);
|
||||
}
|
||||
return this.coordinate_;
|
||||
}
|
||||
set coordinate(coordinate) {
|
||||
this.coordinate_ = coordinate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the default browser action.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault.
|
||||
|
||||
Reference in New Issue
Block a user