Add updateWhileInteracting to olx.layer.VectorOptions

This commit is contained in:
Éric Lemoine
2015-04-01 08:27:29 +02:00
parent 4619cac9ce
commit 42c4ae9ced
5 changed files with 48 additions and 9 deletions

View File

@@ -3397,6 +3397,7 @@ olx.layer.TileOptions.prototype.useInterimTilesOnError;
* source: (ol.source.Vector|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined),
* updateWhileAnimating: (boolean|undefined),
* updateWhileInteracting: (boolean|undefined),
* visible: (boolean|undefined)}}
* @api
*/
@@ -3516,6 +3517,15 @@ olx.layer.VectorOptions.prototype.style;
olx.layer.VectorOptions.prototype.updateWhileAnimating;
/**
* When set to `true`, feature batches will be recreated during interactions.
* See also `updateWhileInteracting`. Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.layer.VectorOptions.prototype.updateWhileInteracting;
/**
* Visibility. Default is `true` (visible).
* @type {boolean|undefined}

View File

@@ -37,6 +37,7 @@ ol.layer.Vector = function(opt_options) {
delete baseOptions.style;
delete baseOptions.renderBuffer;
delete baseOptions.updateWhileAnimating;
delete baseOptions.updateWhileInteracting;
goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions));
/**
@@ -69,6 +70,13 @@ ol.layer.Vector = function(opt_options) {
this.updateWhileAnimating_ = goog.isDef(options.updateWhileAnimating) ?
options.updateWhileAnimating : false;
/**
* @type {boolean}
* @private
*/
this.updateWhileInteracting_ = goog.isDef(options.updateWhileInteracting) ?
options.updateWhileInteracting : false;
};
goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -130,6 +138,15 @@ ol.layer.Vector.prototype.getUpdateWhileAnimating = function() {
};
/**
* @return {boolean} Whether the rendered layer should be updated while
* interacting.
*/
ol.layer.Vector.prototype.getUpdateWhileInteracting = function() {
return this.updateWhileInteracting_;
};
/**
* @param {function(ol.Feature, ol.Feature):number|null|undefined} renderOrder
* Render order.

View File

@@ -169,9 +169,13 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource);
if (!this.dirty_ && (!vectorLayer.getUpdateWhileAnimating() &&
frameState.viewHints[ol.ViewHint.ANIMATING] ||
frameState.viewHints[ol.ViewHint.INTERACTING])) {
var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
if (!this.dirty_ && (!updateWhileAnimating && animating) ||
(!updateWhileInteracting && interacting)) {
return true;
}

View File

@@ -230,9 +230,13 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame =
frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource);
if (!this.dirty_ && (!vectorLayer.getUpdateWhileAnimating() &&
frameState.viewHints[ol.ViewHint.ANIMATING] ||
frameState.viewHints[ol.ViewHint.INTERACTING])) {
var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
if (!this.dirty_ && (!updateWhileAnimating && animating) ||
(!updateWhileInteracting && interacting)) {
return true;
}

View File

@@ -202,9 +202,13 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource);
if (!this.dirty_ && (!vectorLayer.getUpdateWhileAnimating() &&
frameState.viewHints[ol.ViewHint.ANIMATING] ||
frameState.viewHints[ol.ViewHint.INTERACTING])) {
var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
if (!this.dirty_ && (!updateWhileAnimating && animating) ||
(!updateWhileInteracting && interacting)) {
return true;
}