[Pkg-javascript-commits] [leaflet-markercluster] 67/128: Refresh icons after bulk action, not during one

Jonas Smedegaard dr at jones.dk
Sun Apr 16 06:26:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit 53c1f94a1dc3af6c0112d88aa91532683d8c9b36
Author: Michał Łazowik <mlazowik at gmail.com>
Date:   Mon Jul 18 19:19:56 2016 +0200

    Refresh icons after bulk action, not during one
---
 src/MarkerClusterGroup.Refresh.js | 13 -------------
 src/MarkerClusterGroup.js         | 36 +++++++++++++++++++++---------------
 2 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/src/MarkerClusterGroup.Refresh.js b/src/MarkerClusterGroup.Refresh.js
index f8f8eab..a1320b0 100644
--- a/src/MarkerClusterGroup.Refresh.js
+++ b/src/MarkerClusterGroup.Refresh.js
@@ -62,19 +62,6 @@ L.MarkerClusterGroup.include({
 	},
 
 	/**
-	 * Refreshes the icon of all "dirty" visible clusters.
-	 * Non-visible "dirty" clusters will be updated when they are added to the map.
-	 * @private
-	 */
-	_refreshClustersIcons: function () {
-		this._featureGroup.eachLayer(function (c) {
-			if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
-				c._updateIcon();
-			}
-		});
-	},
-
-	/**
 	 * Re-draws the icon of the supplied markers.
 	 * To be used in singleMarkerMode only.
 	 * @param layers Array(L.Marker)|Map(L.Marker) list of markers.
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 05679aa..07e0ef8 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -104,6 +104,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		// Refresh bounds and weighted positions.
 		this._topClusterLevel._recalculateBounds();
 
+		this._refreshClustersIcons();
+
 		//Work out what is visible
 		var visibleLayer = layer,
 			currentZoom = this._map.getZoom();
@@ -157,6 +159,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		// Refresh bounds and weighted positions.
 		this._topClusterLevel._recalculateBounds();
 
+		this._refreshClustersIcons();
+
 		layer.off('move', this._childMarkerMoved, this);
 
 		if (this._featureGroup.hasLayer(layer)) {
@@ -249,12 +253,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 					// Refresh bounds and weighted positions.
 					this._topClusterLevel._recalculateBounds();
 
-					//Update the icons of all those visible clusters that were affected
-					this._featureGroup.eachLayer(function (c) {
-						if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
-							c._updateIcon();
-						}
-					});
+					this._refreshClustersIcons();
 
 					this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
 				} else {
@@ -380,15 +379,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		// Refresh bounds and weighted positions.
 		this._topClusterLevel._recalculateBounds();
 
+		this._refreshClustersIcons();
+
 		//Fix up the clusters and markers on the map
 		this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
 
-		fg.eachLayer(function (c) {
-			if (c instanceof L.MarkerCluster) {
-				c._updateIcon();
-			}
-		});
-
 		return this;
 	},
 
@@ -717,9 +712,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 					}
 				}
 			} else {
-				if (!dontUpdateMap || !cluster._icon) {
-					cluster._updateIcon();
-				}
+				cluster._iconNeedsUpdate = true;
 			}
 
 			cluster = cluster.__parent;
@@ -968,6 +961,19 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		return;
 	},
 
+	/**
+	 * Refreshes the icon of all "dirty" visible clusters.
+	 * Non-visible "dirty" clusters will be updated when they are added to the map.
+	 * @private
+	 */
+	_refreshClustersIcons: function () {
+		this._featureGroup.eachLayer(function (c) {
+			if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
+				c._updateIcon();
+			}
+		});
+	},
+
 	//Enqueue code to fire after the marker expand/contract has happened
 	_enqueue: function (fn) {
 		this._queue.push(fn);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git



More information about the Pkg-javascript-commits mailing list