Fire moveend only once after view settles

This commit is contained in:
Tim Schaub
2014-05-13 16:37:23 -06:00
parent 2d34d04113
commit df05e9da11
2 changed files with 69 additions and 3 deletions

View File

@@ -212,6 +212,13 @@ ol.Map = function(options) {
*/
this.frameState_ = null;
/**
* The extent at the previous 'moveend' event.
* @private
* @type {ol.Extent}
*/
this.previousExtent_ = null;
/**
* @private
* @type {goog.events.Key}
@@ -1235,12 +1242,15 @@ ol.Map.prototype.renderFrame_ = function(time) {
this.postRenderFunctions_, frameState.postRenderFunctions);
var idle = this.preRenderFunctions_.length === 0 &&
!frameState.animate &&
!frameState.viewHints[ol.ViewHint.ANIMATING] &&
!frameState.viewHints[ol.ViewHint.INTERACTING];
!frameState.viewHints[ol.ViewHint.INTERACTING] &&
(!this.previousExtent_ ||
!ol.extent.equals(frameState.extent, this.previousExtent_));
if (idle) {
this.dispatchEvent(new ol.MapEvent(ol.MapEventType.MOVEEND, this));
this.dispatchEvent(
new ol.MapEvent(ol.MapEventType.MOVEEND, this, frameState));
this.previousExtent_ = ol.extent.clone(frameState.extent);
}
}