From 60dbe93f7fcbae5e2ee5f1ef478f9ed85168f093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Peru=C4=8Di=C4=87?= Date: Mon, 30 Mar 2015 15:01:23 +0200 Subject: [PATCH] fix: set pendingFeatures_ as object on init --- src/ol/interaction/snapinteraction.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index 898bd0d15a..2c3b097995 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -94,6 +94,15 @@ ol.interaction.Snap = function(opt_options) { */ this.indexedFeaturesExtents_ = {}; + /** + * If a feature geometry changes while a pointer drag|move event occurs, the + * feature doesn't get updated right away. It will be at the next 'pointerup' + * event fired. + * @type {Object.} + * @private + */ + this.pendingFeatures_ = {}; + /** * Used for distance sorting in sortByDistance_ * @type {ol.Coordinate} @@ -174,16 +183,6 @@ goog.exportProperty( ol.interaction.Snap.prototype.addFeature); -/** - * If a feature geometry changes while a pointer drag|move event occurs, the - * feature doesn't get updated right away. It will be at the next 'pointerup' - * event fired. - * @type {Object.} - * @private - */ -ol.interaction.Snap.prototype.pendingFeatures_ = null; - - /** * @param {ol.Feature} feature Feature. * @private @@ -602,9 +601,11 @@ ol.interaction.Snap.handleEvent_ = function(evt) { * @private */ ol.interaction.Snap.handleUpEvent_ = function(evt) { - goog.array.forEach(goog.object.getValues(this.pendingFeatures_), - this.updateFeature_, this); - this.pendingFeatures_ = {}; + var featuresToUpdate = goog.object.getValues(this.pendingFeatures_); + if (featuresToUpdate.length) { + goog.array.forEach(featuresToUpdate, this.updateFeature_, this); + this.pendingFeatures_ = {}; + } return false; };