From ab28c4833827c7bee0796e504747e781afa7dae6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 14 Feb 2018 14:51:51 +0100 Subject: [PATCH] Only compute the viewState focus when it's needed --- src/ol/PluggableMap.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 82bd7dee49..83c1869fce 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -1208,15 +1208,18 @@ PluggableMap.prototype.renderFrame_ = function(time) { layerStates[getUid(layerStatesArray[i].layer)] = layerStatesArray[i]; } viewState = view.getState(); - const center = viewState.center; - const pixelResolution = viewState.resolution / this.pixelRatio_; - center[0] = Math.round(center[0] / pixelResolution) * pixelResolution; - center[1] = Math.round(center[1] / pixelResolution) * pixelResolution; + let focus = this.focus_; + if (!focus) { + focus = viewState.center; + 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} */ ({ animate: false, coordinateToPixelTransform: this.coordinateToPixelTransform_, extent: extent, - focus: !this.focus_ ? center : this.focus_, + focus: focus, index: this.frameIndex_++, layerStates: layerStates, layerStatesArray: layerStatesArray,