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