Don't call view.getState in DragPan interaction

Reduce garbage generation from the function response (Object)
This commit is contained in:
Frederic Junod
2018-02-14 14:37:38 +01:00
parent e2854b3176
commit d9a6121058

View File

@@ -77,11 +77,10 @@ function handleDragEvent(mapBrowserEvent) {
const deltaY = centroid[1] - this.lastCentroid[1];
const map = mapBrowserEvent.map;
const view = map.getView();
const viewState = view.getState();
let center = [deltaX, deltaY];
scaleCoordinate(center, viewState.resolution);
rotateCoordinate(center, viewState.rotation);
addCoordinate(center, viewState.center);
scaleCoordinate(center, view.getResolution());
rotateCoordinate(center, view.getRotation());
addCoordinate(center, view.getCenter());
center = view.constrainCenter(center);
view.setCenter(center);
}