[Pkg-javascript-commits] [leaflet-markercluster] 18/479: Make _inZoomAnimation a counter rather than a boolean to allow for overlapping zoom animations.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:04 UTC 2014


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

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

commit 9447fc468f368cdf2accb762d8f064c5ca91ae24
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 13 16:18:09 2012 +1200

    Make _inZoomAnimation a counter rather than a boolean to allow for overlapping zoom animations.
---
 src/MarkerClusterGroup.js | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 47eb255..b508d5d 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -27,6 +27,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		L.FeatureGroup.prototype.initialize.call(this, []);
 
+		this._inZoomAnimation = 0;
 		this._needsClustering = [];
 
 		this._markersAndClustersAtZoom = {};
@@ -48,7 +49,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	},
 
 	_moveEnd: function () {
-		if (this._inZoomAnimation) {
+		if (this._inZoomAnimation > 0) {
 			return;
 		}
 
@@ -446,7 +447,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 		}
 
 
-		this._inZoomAnimation = true;
+		this._inZoomAnimation++;
 		//Start up a function to update the positions of the just added clusters/markers
 		//This must happen after otherwise they don't get animated
 		setTimeout(function () {
@@ -457,12 +458,10 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 
 			setTimeout(function () {
 				map._mapPane.className = map._mapPane.className.replace(' leaflet-cluster-anim', '');
-				me._inZoomAnimation = false;
+				me._inZoomAnimation--;
 			}, 250);
 		}, 0);
 	},
-	_animationZoomOutTimeout: null,
-	_animationZoomOutTimeoutFunction: null,
 	_animationZoomOut: function (newClusters, newUnclustered, depth) {
 		var map = this._map,
 		    bounds = this._getExpandedVisibleBounds(),
@@ -479,13 +478,13 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 				c._icon.style.visibility='hidden';
 			}
 		}
-		this._inZoomAnimation = true;
+		this._inZoomAnimation++;
 
 		var me = this;
 		console.log(new Date().getTime() + ' called at zoom ' + me._map._zoom);
 		
 		//TODO: Maybe use the transition timing stuff to make this more reliable
-		this._animationZoomOutTimeoutFunction = function () {
+		setTimeout(function () {
 
 			map._mapPane.className = map._mapPane.className.replace(' leaflet-cluster-anim', '');
 			console.log(new Date().getTime() + ' adding at zoom ' + me._map._zoom);
@@ -502,12 +501,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 					L.FeatureGroup.prototype.addLayer.call(me, m); //TODO Animate
 				}
 			}
-			me._inZoomAnimation = false;
-		};
-		this._animationZoomOutTimeout = setTimeout(function() {
-			me._animationZoomOutTimeoutFunction();
-			me._animationZoomOutTimeout = null;
-			me._animationZoomOutTimeoutFunction = null;
+			me._inZoomAnimation--;
 		}, 250);
 	}
 });
\ No newline at end of file

-- 
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