Skip to content

Commit c97e6db

Browse files
committed
Add updateVectorsWhileAnimating option
With this option, vector batches will be recreated with every frame. For animations, this means that vector data won't be clipped to the extent at which the animation started.
1 parent 35468e2 commit c97e6db

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

externs/olx.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ olx.interaction.InteractionOptions.prototype.handleEvent;
178178
* overlays: (ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined),
179179
* renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined),
180180
* target: (Element|string|undefined),
181+
* updateVectorsWhileAnimating: (boolean|undefined),
181182
* view: (ol.View|undefined)}}
182183
* @api
183184
*/
@@ -294,6 +295,16 @@ olx.MapOptions.prototype.renderer;
294295
olx.MapOptions.prototype.target;
295296

296297

298+
/**
299+
* When set to true, vectors will be rendered immediately as they pan into view.
300+
* This means that no vectors will be shown clipped, but the setting will have a
301+
* performance impact for large amounts of vector data.
302+
* Default is `false`.
303+
* @type {boolean|undefined}
304+
*/
305+
olx.MapOptions.prototype.updateVectorsWhileAnimating;
306+
307+
297308
/**
298309
* The map's view. No layer sources will be fetched unless this is specified at
299310
* construction time or through {@link ol.Map#setView}.

src/ol/map.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ ol.Map = function(options) {
187187
this.pixelRatio_ = goog.isDef(options.pixelRatio) ?
188188
options.pixelRatio : ol.has.DEVICE_PIXEL_RATIO;
189189

190+
/**
191+
* @type {boolean}
192+
* @private
193+
*/
194+
this.updateVectorsWhileAnimating_ =
195+
goog.isDef(options.updateVectorsWhileAnimating) ?
196+
options.updateVectorsWhileAnimating : false;
197+
190198
/**
191199
* @private
192200
* @type {Object}
@@ -1234,6 +1242,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
12341242
animate: false,
12351243
attributions: {},
12361244
coordinateToPixelMatrix: this.coordinateToPixelMatrix_,
1245+
updateVectorsWhileAnimating: this.updateVectorsWhileAnimating_,
12371246
extent: null,
12381247
focus: goog.isNull(this.focus_) ? viewState.center : this.focus_,
12391248
index: this.frameIndex_++,

src/ol/renderer/canvas/canvasvectorlayerrenderer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
169169
frameState.attributions, vectorSource.getAttributions());
170170
this.updateLogos(frameState, vectorSource);
171171

172-
if (!this.dirty_ && (frameState.viewHints[ol.ViewHint.ANIMATING] ||
172+
if (!this.dirty_ && (!frameState.updateVectorsWhileAnimating &&
173+
frameState.viewHints[ol.ViewHint.ANIMATING] ||
173174
frameState.viewHints[ol.ViewHint.INTERACTING])) {
174175
return true;
175176
}

0 commit comments

Comments
 (0)