@@ -7,7 +7,7 @@ import {scale as scaleCoordinate, rotate as rotateCoordinate, add as addCoordina
|
||||
import {easeOut} from '../easing.js';
|
||||
import {noModifierKeys} from '../events/condition.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -67,7 +67,7 @@ inherits(DragPan, PointerInteraction);
|
||||
*/
|
||||
function handleDragEvent(mapBrowserEvent) {
|
||||
const targetPointers = this.targetPointers;
|
||||
const centroid = PointerInteraction.centroid(targetPointers);
|
||||
const centroid = centroidFromPointers(targetPointers);
|
||||
if (targetPointers.length == this.lastPointersCount_) {
|
||||
if (this.kinetic_) {
|
||||
this.kinetic_.update(centroid[0], centroid[1]);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
|
||||
import {disable} from '../rotationconstraint.js';
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ function handleDragEvent(mapBrowserEvent) {
|
||||
// FIXME: should be the intersection point between the lines:
|
||||
// touch0,touch1 and previousTouch0,previousTouch1
|
||||
const viewportPosition = map.getViewport().getBoundingClientRect();
|
||||
const centroid = PointerInteraction.centroid(this.targetPointers);
|
||||
const centroid = centroidFromPointers(this.targetPointers);
|
||||
centroid[0] -= viewportPosition.left;
|
||||
centroid[1] -= viewportPosition.top;
|
||||
this.anchor_ = map.getCoordinateFromPixel(centroid);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -103,7 +103,7 @@ function handleDragEvent(mapBrowserEvent) {
|
||||
|
||||
// scale anchor point.
|
||||
const viewportPosition = map.getViewport().getBoundingClientRect();
|
||||
const centroid = PointerInteraction.centroid(this.targetPointers);
|
||||
const centroid = centroidFromPointers(this.targetPointers);
|
||||
centroid[0] -= viewportPosition.left;
|
||||
centroid[1] -= viewportPosition.top;
|
||||
this.anchor_ = map.getCoordinateFromPixel(centroid);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -8,7 +8,7 @@ import {asArray} from '../color.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import IconAnchorUnits from '../style/IconAnchorUnits.js';
|
||||
import IconImage from '../style/IconImage.js';
|
||||
import {get as getIconImage} from '../style/IconImage.js';
|
||||
import IconOrigin from '../style/IconOrigin.js';
|
||||
import ImageStyle from '../style/Image.js';
|
||||
|
||||
@@ -107,7 +107,7 @@ const Icon = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.style.IconImage}
|
||||
*/
|
||||
this.iconImage_ = IconImage.get(
|
||||
this.iconImage_ = getIconImage(
|
||||
image, /** @type {string} */ (src), imgSize, this.crossOrigin_, imageState, this.color_);
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,7 @@ import {iconImageCache} from '../style.js';
|
||||
* @param {ol.Color} color Color.
|
||||
* @extends {ol.events.EventTarget}
|
||||
*/
|
||||
const IconImage = function(image, src, size, crossOrigin, imageState,
|
||||
color) {
|
||||
const IconImage = function(image, src, size, crossOrigin, imageState, color) {
|
||||
|
||||
EventTarget.call(this);
|
||||
|
||||
@@ -101,16 +100,14 @@ inherits(IconImage, EventTarget);
|
||||
* @param {ol.Color} color Color.
|
||||
* @return {ol.style.IconImage} Icon image.
|
||||
*/
|
||||
IconImage.get = function(image, src, size, crossOrigin, imageState,
|
||||
color) {
|
||||
export function get(image, src, size, crossOrigin, imageState, color) {
|
||||
let iconImage = iconImageCache.get(src, crossOrigin, color);
|
||||
if (!iconImage) {
|
||||
iconImage = new IconImage(
|
||||
image, src, size, crossOrigin, imageState, color);
|
||||
iconImage = new IconImage(image, src, size, crossOrigin, imageState, color);
|
||||
iconImageCache.set(src, crossOrigin, color, iconImage);
|
||||
}
|
||||
return iconImage;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user