Only compute the viewState focus when it's needed

This commit is contained in:
Frederic Junod
2018-02-14 14:51:51 +01:00
parent d9a6121058
commit ab28c48338

View File

@@ -1208,15 +1208,18 @@ PluggableMap.prototype.renderFrame_ = function(time) {
layerStates[getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
}
viewState = view.getState();
const center = viewState.center;
let focus = this.focus_;
if (!focus) {
focus = viewState.center;
const pixelResolution = viewState.resolution / this.pixelRatio_;
center[0] = Math.round(center[0] / pixelResolution) * pixelResolution;
center[1] = Math.round(center[1] / pixelResolution) * pixelResolution;
focus[0] = Math.round(focus[0] / pixelResolution) * pixelResolution;
focus[1] = Math.round(focus[1] / pixelResolution) * pixelResolution;
}
frameState = /** @type {olx.FrameState} */ ({
animate: false,
coordinateToPixelTransform: this.coordinateToPixelTransform_,
extent: extent,
focus: !this.focus_ ? center : this.focus_,
focus: focus,
index: this.frameIndex_++,
layerStates: layerStates,
layerStatesArray: layerStatesArray,