Named exports from ol/interaction/Pointer

This commit is contained in:
Frederic Junod
2018-02-21 16:52:00 +01:00
parent 190449e816
commit fa1fcc79b6
4 changed files with 11 additions and 12 deletions

View File

@@ -86,7 +86,7 @@ inherits(PointerInteraction, Interaction);
* @param {Array.<ol.pointer.PointerEvent>} pointerEvents List of events.
* @return {ol.Pixel} Centroid pixel.
*/
PointerInteraction.centroid = function(pointerEvents) {
export function centroid(pointerEvents) {
const length = pointerEvents.length;
let clientX = 0;
let clientY = 0;
@@ -95,21 +95,20 @@ PointerInteraction.centroid = function(pointerEvents) {
clientY += pointerEvents[i].clientY;
}
return [clientX / length, clientY / length];
};
}
/**
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Whether the event is a pointerdown, pointerdrag
* or pointerup event.
* @private
*/
PointerInteraction.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent) {
function isPointerDraggingEvent(mapBrowserEvent) {
const type = mapBrowserEvent.type;
return type === MapBrowserEventType.POINTERDOWN ||
type === MapBrowserEventType.POINTERDRAG ||
type === MapBrowserEventType.POINTERUP;
};
}
/**
@@ -117,7 +116,7 @@ PointerInteraction.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent)
* @private
*/
PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent) {
if (this.isPointerDraggingEvent_(mapBrowserEvent)) {
if (isPointerDraggingEvent(mapBrowserEvent)) {
const event = mapBrowserEvent.pointerEvent;
const id = event.pointerId.toString();