From 0762b8c0230107853143305dfd4db133f295b60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 26 Jun 2014 10:03:23 +0200 Subject: [PATCH] Defer selection/deselection --- src/ol/interaction/selectinteraction.js | 11 +++++++++-- src/ol/map.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index a926065dee..8d3f727ce1 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -150,6 +150,8 @@ ol.interaction.Select.prototype.handleMapBrowserEvent = } } else { // Modify the currently selected feature(s). + var /** @type {Array.} */ deselected = []; + var /** @type {Array.} */ selected = []; map.forEachFeatureAtPixel(mapBrowserEvent.pixel, /** * @param {ol.Feature} feature Feature. @@ -159,14 +161,19 @@ ol.interaction.Select.prototype.handleMapBrowserEvent = var index = goog.array.indexOf(features.getArray(), feature); if (index == -1) { if (add || toggle) { - features.push(feature); + selected.push(feature); } } else { if (remove || toggle) { - features.removeAt(index); + deselected.push(index); } } }, undefined, this.layerFilter_); + var i; + for (i = deselected.length - 1; i >= 0; --i) { + features.removeAt(deselected[i]); + } + features.extend(selected); } return false; }; diff --git a/src/ol/map.js b/src/ol/map.js index a1e2d0fb72..6412a15574 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1202,7 +1202,7 @@ ol.Map.prototype.renderFrame_ = function(time) { pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_, postRenderFunctions: [], size: size, - skippedFeatureUids_: goog.object.clone(this.skippedFeatureUids_), + skippedFeatureUids_: this.skippedFeatureUids_, tileQueue: this.tileQueue_, time: time, usedTiles: {},