[Pkg-javascript-commits] [leaflet-markercluster] 134/219: Added animate option

Jonas Smedegaard dr at jones.dk
Sat May 7 09:39:27 UTC 2016


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

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

commit 52d238af5b2f0a0a0ded947fe5c841a8cd7c9afd
Author: ghybs <ghybs1 at gmail.com>
Date:   Fri Oct 16 11:28:07 2015 +0400

    Added animate option
    
    Deleted previous branch animationOption since I messed up trying to rebase...
    
    Following issues #382, #348 and PR #352, added a new option `animate` to
    `L.MarkerClusterGroup` to select the animation behaviour.
    
    It defaults to true and its effect is ignored if `L.DomUtil.TRANSITION` is
    false, so that MCG keeps the current behaviour (it animates or not depending
    on `L.DomUtil.TRANSITION`) when this option is left unassigned.
    
    The only difference is that its effect is determined at instanciation time
    instead of at script loading time.
    
    To achieve this, this code removes the test condition when including the
    animation (or non-animation) methods. It adds all methods to prototype, and
    hooks to the appropriate one at initialization.
    `L.MarkerCluster` is also adapted, because it animates when spiderfying.
    In order to avoid having to hook at each instanciation, this code actually
    creates an extended class `L.MarkerClusterNonAnimated` which includes the
    non-animated methods. Then `L.MarkerClusterGroup` instantiates the appropriate
    class.
    
    Also created a dedicated test spec and included it into spec/index.
    
    Finally updated README to describe this new option and its effect on
    `animateAddingMarkers` option.
---
 README.md                        |   3 +-
 spec/index.html                  |   1 +
 spec/suites/animateOptionSpec.js | 190 ++++++++++++++++++++++++++++
 src/MarkerCluster.Spiderfier.js  |   6 +-
 src/MarkerClusterGroup.js        | 260 +++++++++++++++++++++------------------
 5 files changed, 335 insertions(+), 125 deletions(-)

diff --git a/README.md b/README.md
index ceea841..3743b14 100644
--- a/README.md
+++ b/README.md
@@ -61,9 +61,10 @@ Enabled by default (boolean options):
 * **zoomToBoundsOnClick**: When you click a cluster we zoom to its bounds.
 * **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note: the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.*)
 * **removeOutsideVisibleBounds**: Clusters and markers too far from the viewport are removed from the map for performance.
+* **animate**: Smoothly split / merge cluster children when zooming and spiderfying. If `L.DomUtil.TRANSITION` is false, this option has no effect (no animation is possible).
 
 Other options
-* **animateAddingMarkers**: If set to true then adding individual markers to the MarkerClusterGroup after it has been added to the map will add the marker and animate it in to the cluster. Defaults to false as this gives better performance when bulk adding markers. addLayers does not support this, only addLayer with individual Markers.
+* **animateAddingMarkers**: If set to true (and `animate` option is also true) then adding individual markers to the MarkerClusterGroup after it has been added to the map will add the marker and animate it into the cluster. Defaults to false as this gives better performance when bulk adding markers. addLayers does not support this, only addLayer with individual Markers.
 * **disableClusteringAtZoom**: If set, at this zoom level and below markers will not be clustered. This defaults to disabled. [See Example](http://leaflet.github.com/Leaflet.markercluster/example/marker-clustering-realworld-maxzoom.388.html)
 * **maxClusterRadius**: The maximum radius that a cluster will cover from the central marker (in pixels). Default 80. Decreasing will make more, smaller clusters. You can also use a function that accepts the current map zoom and returns the maximum cluster radius in pixels.
 * **polygonOptions**: Options to pass when creating the L.Polygon(points, options) to show the bounds of a cluster
diff --git a/spec/index.html b/spec/index.html
index 403c44b..f25b59a 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -36,6 +36,7 @@
 	<script type="text/javascript" src="suites/AddLayer.MultipleSpec.js"></script>
 	<script type="text/javascript" src="suites/AddLayer.SingleSpec.js"></script>
 	<script type="text/javascript" src="suites/AddLayersSpec.js"></script>
+	<script type="text/javascript" src="suites/animateOptionSpec.js"></script>
 
 	<script type="text/javascript" src="suites/ChildChangingIconSupportSpec.js"></script>
 
diff --git a/spec/suites/animateOptionSpec.js b/spec/suites/animateOptionSpec.js
new file mode 100644
index 0000000..c99ee7d
--- /dev/null
+++ b/spec/suites/animateOptionSpec.js
@@ -0,0 +1,190 @@
+describe('animate option', function () {
+
+	/**
+	 * Wrapper for Mocha's `it` function, to avoid using `beforeEach` and `afterEach`
+	 * which create problems with PhantomJS when total number of tests (across all suites)
+	 * increases. Might be due to use of promises for which PhantomJS would performs badly?
+	 * NOTE: works only with synchronous code.
+	 * @param testDescription string
+	 * @param testInstructions function
+	 * @param testFinally function to be executed just before afterEach2, in the `finally` block.
+	 */
+	function it2(testDescription, testInstructions, testFinally) {
+
+		it(testDescription, function () {
+
+			// Before each test.
+			if (typeof beforeEach2 === "function") {
+				beforeEach2();
+			}
+
+			try {
+
+				// Perform the actual test instructions.
+				testInstructions();
+
+			} catch (e) {
+
+				// Re-throw the exception so that Mocha sees the failed test.
+				throw e;
+
+			} finally {
+
+				// If specific final instructions are provided.
+				if (typeof testFinally === "function") {
+					testFinally();
+				}
+
+				// After each test.
+				if (typeof afterEach2 === "function") {
+					afterEach2();
+				}
+
+			}
+		});
+	}
+
+
+	/////////////////////////////
+	// SETUP FOR EACH TEST
+	/////////////////////////////
+
+	/**
+	 * Instructions to be executed before each test called with `it2`.
+	 */
+	function beforeEach2() {
+
+		// Nothing for this test suite.
+
+	}
+
+	/**
+	 * Instructions to be executed after each test called with `it2`.
+	 */
+	function afterEach2() {
+
+		if (group instanceof L.MarkerClusterGroup) {
+			group.removeLayers(group.getLayers());
+			map.removeLayer(group);
+		}
+
+		// Throw away group as it can be assigned with different configurations between tests.
+		group = null;
+	}
+
+
+	/////////////////////////////
+	// PREPARATION CODE
+	/////////////////////////////
+
+	var div, map, group, previousTransitionSetting;
+
+	div = document.createElement('div');
+	div.style.width = '200px';
+	div.style.height = '200px';
+	document.body.appendChild(div);
+
+	map = L.map(div, { maxZoom: 18 });
+
+	// Corresponds to zoom level 8 for the above div dimensions.
+	map.fitBounds(new L.LatLngBounds([
+		[1, 1],
+		[2, 2]
+	]));
+
+
+	/////////////////////////////
+	// TESTS
+	/////////////////////////////
+
+	it2('hooks animated methods version by default', function () {
+
+		// Need to add to map so that we have the top cluster level created.
+		group = L.markerClusterGroup().addTo(map);
+
+		var withAnimation = L.MarkerClusterGroup.prototype._withAnimation;
+
+		// MCG animated methods.
+		expect(group._animationStart).to.be(withAnimation._animationStart);
+		expect(group._animationZoomIn).to.be(withAnimation._animationZoomIn);
+		expect(group._animationZoomOut).to.be(withAnimation._animationZoomOut);
+		expect(group._animationAddLayer).to.be(withAnimation._animationAddLayer);
+
+		// MarkerCluster spiderfy animated methods
+		var cluster = group._topClusterLevel;
+
+		withAnimation = L.MarkerCluster.prototype;
+
+		expect(cluster._animationSpiderfy).to.be(withAnimation._animationSpiderfy);
+		expect(cluster._animationUnspiderfy).to.be(withAnimation._animationUnspiderfy);
+
+	});
+
+	it2('hooks non-animated methods version when set to false', function () {
+
+		// Need to add to map so that we have the top cluster level created.
+		group = L.markerClusterGroup({animate: false}).addTo(map);
+
+		var noAnimation = L.MarkerClusterGroup.prototype._noAnimation;
+
+		// MCG non-animated methods.
+		expect(group._animationStart).to.be(noAnimation._animationStart);
+		expect(group._animationZoomIn).to.be(noAnimation._animationZoomIn);
+		expect(group._animationZoomOut).to.be(noAnimation._animationZoomOut);
+		expect(group._animationAddLayer).to.be(noAnimation._animationAddLayer);
+
+		// MarkerCluster spiderfy non-animated methods
+		var cluster = group._topClusterLevel;
+
+		noAnimation = L.MarkerClusterNonAnimated.prototype;
+
+		expect(cluster._animationSpiderfy).to.be(noAnimation._animationSpiderfy);
+		expect(cluster._animationUnspiderfy).to.be(noAnimation._animationUnspiderfy);
+
+	});
+
+	it2(
+		'always hooks non-animated methods version when L.DomUtil.TRANSITION is false',
+
+		function () {
+
+			previousTransitionSetting = L.DomUtil.TRANSITION;
+			// Fool Leaflet, make it think the browser does not support transitions.
+			L.DomUtil.TRANSITION = false;
+
+			// Need to add to map so that we have the top cluster level created.
+			group = L.markerClusterGroup({animate: true}).addTo(map);
+
+			var noAnimation = L.MarkerClusterGroup.prototype._noAnimation;
+
+			// MCG non-animated methods.
+			expect(group._animationStart).to.be(noAnimation._animationStart);
+			expect(group._animationZoomIn).to.be(noAnimation._animationZoomIn);
+			expect(group._animationZoomOut).to.be(noAnimation._animationZoomOut);
+			expect(group._animationAddLayer).to.be(noAnimation._animationAddLayer);
+
+			// MarkerCluster spiderfy non-animated methods
+			var cluster = group._topClusterLevel;
+
+			noAnimation = L.MarkerClusterNonAnimated.prototype;
+
+			expect(cluster._animationSpiderfy).to.be(noAnimation._animationSpiderfy);
+			expect(cluster._animationUnspiderfy).to.be(noAnimation._animationUnspiderfy);
+
+		},
+
+		function () {
+			// Restore previous setting so that next tests are unaffected.
+			L.DomUtil.TRANSITION = previousTransitionSetting;
+		}
+	);
+
+
+	/////////////////////////////
+	// CLEAN UP CODE
+	/////////////////////////////
+
+	map.remove();
+	document.body.removeChild(div);
+
+});
diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index 9ef784a..5fa175d 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -116,7 +116,7 @@ L.MarkerCluster.include({
 	}
 });
 
-L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
+L.MarkerClusterNonAnimated = L.MarkerCluster.extend({
 	//Non Animated versions of everything
 	_animationSpiderfy: function (childMarkers, positions) {
 		var group = this._group,
@@ -148,7 +148,9 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 	_animationUnspiderfy: function () {
 		this._noanimationUnspiderfy();
 	}
-} : {
+});
+
+L.MarkerCluster.include({
 	//Animated versions here
 	SVG_ANIMATION: (function () {
 		return document.createElementNS('http://www.w3.org/2000/svg', 'animate').toString().indexOf('SVGAnimate') > -1;
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 37f080f..b817a20 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -19,6 +19,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		// is the default behaviour for performance reasons.
 		removeOutsideVisibleBounds: true,
 
+		// Set to false to disable all animations (zoom and spiderfy).
+		// If false, option animateAddingMarkers below has no effect.
+		// If L.DomUtil.TRANSITION is falsy, this option has no effect.
+		animate: true,
+
 		//Whether to animate adding markers after adding the MarkerClusterGroup to the map
 		// If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains.
 		animateAddingMarkers: false,
@@ -58,6 +63,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		this._currentShownBounds = null;
 
 		this._queue = [];
+
+		// Hook the appropriate animation methods.
+		var animate = L.DomUtil.TRANSITION && this.options.animate;
+		L.extend(this, animate ? this._withAnimation : this._noAnimation);
+		// Remember which MarkerCluster class to instantiate (animated or not).
+		this._markerCluster = animate ? L.MarkerCluster : L.MarkerClusterNonAnimated;
 	},
 
 	addLayer: function (layer) {
@@ -772,7 +783,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			this._gridUnclustered[zoom] = new L.DistanceGrid(radiusFn(zoom));
 		}
 
-		this._topClusterLevel = new L.MarkerCluster(this, -1);
+		// Instantiate the appropriate L.MarkerCluster class (animated or not).
+		this._topClusterLevel = new this._markerCluster(this, -1);
 	},
 
 	//Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom)
@@ -814,7 +826,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 				//Create new cluster with these 2 in it
 
-				var newCluster = new L.MarkerCluster(this, zoom, closest, layer);
+				var newCluster = new this._markerCluster(this, zoom, closest, layer);
 				gridClusters[zoom].addObject(newCluster, this._map.project(newCluster._cLatLng, zoom));
 				closest.__parent = newCluster;
 				layer.__parent = newCluster;
@@ -822,7 +834,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 				//First create any new intermediate parent clusters that don't exist
 				var lastParent = newCluster;
 				for (z = zoom - 1; z > parent._zoom; z--) {
-					lastParent = new L.MarkerCluster(this, z, lastParent);
+					lastParent = new this._markerCluster(this, z, lastParent);
 					gridClusters[z].addObject(lastParent, this._map.project(closest.getLatLng(), z));
 				}
 				parent._addChild(lastParent);
@@ -917,114 +929,140 @@ L.MarkerClusterGroup.include({
 	_mapBoundsInfinite: new L.LatLngBounds(new L.LatLng(-Infinity, -Infinity), new L.LatLng(Infinity, Infinity))
 });
 
-L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
-
-	//Non Animated versions of everything
-	_animationStart: function () {
-		//Do nothing...
-	},
-	_animationZoomIn: function (previousZoomLevel, newZoomLevel) {
-		this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel);
-		this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
-
-		//We didn't actually animate, but we use this event to mean "clustering animations have finished"
-		this.fire('animationend');
-	},
-	_animationZoomOut: function (previousZoomLevel, newZoomLevel) {
-		this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel);
-		this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
-
-		//We didn't actually animate, but we use this event to mean "clustering animations have finished"
-		this.fire('animationend');
-	},
-	_animationAddLayer: function (layer, newCluster) {
-		this._animationAddLayerNonAnimated(layer, newCluster);
-	}
-} : {
-
-	//Animated versions here
-	_animationStart: function () {
-		this._map._mapPane.className += ' leaflet-cluster-anim';
-		this._inZoomAnimation++;
-	},
-	_animationEnd: function () {
-		if (this._map) {
-			this._map._mapPane.className = this._map._mapPane.className.replace(' leaflet-cluster-anim', '');
+L.MarkerClusterGroup.include({
+	_noAnimation: {
+		//Non Animated versions of everything
+		_animationStart: function () {
+			//Do nothing...
+		},
+		_animationZoomIn: function (previousZoomLevel, newZoomLevel) {
+			this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel);
+			this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
+
+			//We didn't actually animate, but we use this event to mean "clustering animations have finished"
+			this.fire('animationend');
+		},
+		_animationZoomOut: function (previousZoomLevel, newZoomLevel) {
+			this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel);
+			this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
+
+			//We didn't actually animate, but we use this event to mean "clustering animations have finished"
+			this.fire('animationend');
+		},
+		_animationAddLayer: function (layer, newCluster) {
+			this._animationAddLayerNonAnimated(layer, newCluster);
 		}
-		this._inZoomAnimation--;
-		this.fire('animationend');
 	},
-	_animationZoomIn: function (previousZoomLevel, newZoomLevel) {
-		var bounds = this._getExpandedVisibleBounds(),
-		    fg = this._featureGroup,
-		    i;
-
-		//Add all children of current clusters to map and remove those clusters from map
-		this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) {
-			var startPos = c._latlng,
-				markers = c._markers,
-				m;
-
-			if (!bounds.contains(startPos)) {
-				startPos = null;
-			}
+	_withAnimation: {
+		//Animated versions here
+		_animationStart: function () {
+			this._map._mapPane.className += ' leaflet-cluster-anim';
+			this._inZoomAnimation++;
+		},
+		_animationZoomIn: function (previousZoomLevel, newZoomLevel) {
+			var bounds = this._getExpandedVisibleBounds(),
+			    fg     = this._featureGroup,
+			    i;
+
+			//Add all children of current clusters to map and remove those clusters from map
+			this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) {
+				var startPos = c._latlng,
+				    markers  = c._markers,
+				    m;
 
-			if (c._isSingleParent() && previousZoomLevel + 1 === newZoomLevel) { //Immediately add the new child and remove us
-				fg.removeLayer(c);
-				c._recursivelyAddChildrenToMap(null, newZoomLevel, bounds);
-			} else {
-				//Fade out old cluster
-				c.clusterHide();
-				c._recursivelyAddChildrenToMap(startPos, newZoomLevel, bounds);
-			}
+				if (!bounds.contains(startPos)) {
+					startPos = null;
+				}
 
-			//Remove all markers that aren't visible any more
-			//TODO: Do we actually need to do this on the higher levels too?
-			for (i = markers.length - 1; i >= 0; i--) {
-				m = markers[i];
-				if (!bounds.contains(m._latlng)) {
-					fg.removeLayer(m);
+				if (c._isSingleParent() && previousZoomLevel + 1 === newZoomLevel) { //Immediately add the new child and remove us
+					fg.removeLayer(c);
+					c._recursivelyAddChildrenToMap(null, newZoomLevel, bounds);
+				} else {
+					//Fade out old cluster
+					c.clusterHide();
+					c._recursivelyAddChildrenToMap(startPos, newZoomLevel, bounds);
 				}
-			}
 
-		});
+				//Remove all markers that aren't visible any more
+				//TODO: Do we actually need to do this on the higher levels too?
+				for (i = markers.length - 1; i >= 0; i--) {
+					m = markers[i];
+					if (!bounds.contains(m._latlng)) {
+						fg.removeLayer(m);
+					}
+				}
 
-		this._forceLayout();
+			});
 
-		//Update opacities
-		this._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel);
-		//TODO Maybe? Update markers in _recursivelyBecomeVisible
-		fg.eachLayer(function (n) {
-			if (!(n instanceof L.MarkerCluster) && n._icon) {
-				n.clusterShow();
-			}
-		});
+			this._forceLayout();
 
-		//update the positions of the just added clusters/markers
-		this._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function (c) {
-			c._recursivelyRestoreChildPositions(newZoomLevel);
-		});
+			//Update opacities
+			this._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel);
+			//TODO Maybe? Update markers in _recursivelyBecomeVisible
+			fg.eachLayer(function (n) {
+				if (!(n instanceof L.MarkerCluster) && n._icon) {
+					n.clusterShow();
+				}
+			});
 
-		//Remove the old clusters and close the zoom animation
-		this._enqueue(function () {
 			//update the positions of the just added clusters/markers
-			this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) {
-				fg.removeLayer(c);
-				c.clusterShow();
+			this._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function (c) {
+				c._recursivelyRestoreChildPositions(newZoomLevel);
 			});
 
-			this._animationEnd();
-		});
-	},
+			//Remove the old clusters and close the zoom animation
+			this._enqueue(function () {
+				//update the positions of the just added clusters/markers
+				this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) {
+					fg.removeLayer(c);
+					c.clusterShow();
+				});
+
+				this._animationEnd();
+			});
+		},
+
+		_animationZoomOut: function (previousZoomLevel, newZoomLevel) {
+			this._animationZoomOutSingle(this._topClusterLevel, previousZoomLevel - 1, newZoomLevel);
+
+			//Need to add markers for those that weren't on the map before but are now
+			this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
+			//Remove markers that were on the map before but won't be now
+			this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel, this._getExpandedVisibleBounds());
+		},
+		_animationAddLayer: function (layer, newCluster) {
+			var me = this,
+			    fg = this._featureGroup;
+
+			fg.addLayer(layer);
+			if (newCluster !== layer) {
+				if (newCluster._childCount > 2) { //Was already a cluster
+
+					newCluster._updateIcon();
+					this._forceLayout();
+					this._animationStart();
+
+					layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng()));
+					layer.clusterHide();
+
+					this._enqueue(function () {
+						fg.removeLayer(layer);
+						layer.clusterShow();
+
+						me._animationEnd();
+					});
 
-	_animationZoomOut: function (previousZoomLevel, newZoomLevel) {
-		this._animationZoomOutSingle(this._topClusterLevel, previousZoomLevel - 1, newZoomLevel);
+				} else { //Just became a cluster
+					this._forceLayout();
 
-		//Need to add markers for those that weren't on the map before but are now
-		this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
-		//Remove markers that were on the map before but won't be now
-		this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel, this._getExpandedVisibleBounds());
+					me._animationStart();
+					me._animationZoomOutSingle(newCluster, this._map.getMaxZoom(), this._map.getZoom());
+				}
+			}
+		}
 	},
+
+	// Private methods for animated versions.
 	_animationZoomOutSingle: function (cluster, previousZoomLevel, newZoomLevel) {
 		var bounds = this._getExpandedVisibleBounds();
 
@@ -1057,35 +1095,13 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 			me._animationEnd();
 		});
 	},
-	_animationAddLayer: function (layer, newCluster) {
-		var me = this,
-			fg = this._featureGroup;
-
-		fg.addLayer(layer);
-		if (newCluster !== layer) {
-			if (newCluster._childCount > 2) { //Was already a cluster
 
-				newCluster._updateIcon();
-				this._forceLayout();
-				this._animationStart();
-
-				layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng()));
-				layer.clusterHide();
-
-				this._enqueue(function () {
-					fg.removeLayer(layer);
-					layer.clusterShow();
-
-					me._animationEnd();
-				});
-
-			} else { //Just became a cluster
-				this._forceLayout();
-
-				me._animationStart();
-				me._animationZoomOutSingle(newCluster, this._map.getMaxZoom(), this._map.getZoom());
-			}
+	_animationEnd: function () {
+		if (this._map) {
+			this._map._mapPane.className = this._map._mapPane.className.replace(' leaflet-cluster-anim', '');
 		}
+		this._inZoomAnimation--;
+		this.fire('animationend');
 	},
 
 	//Force a browser layout of stuff in the map

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