[Pkg-javascript-commits] [leaflet-markercluster] 84/479: Animate unspiderfying if supported :) Fixes #8

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:13 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 a8dc5f315b457a6936e194be1c398ad310219d97
Author: danzel <danzel at localhost.geek.nz>
Date:   Tue Jul 24 11:51:28 2012 +1200

    Animate unspiderfying if supported :) Fixes #8
---
 src/MarkerCluster.Spiderfier.js | 91 ++++++++++++++++++++++++++++++++---------
 1 file changed, 71 insertions(+), 20 deletions(-)

diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index 2816d43..f5b4113 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -41,24 +41,8 @@ L.MarkerCluster.include({
 	},
 
 	unspiderfy: function () {
-		var group = this._group,
-			map = group._map,
-			childMarkers = this.getAllChildMarkers(),
-			m, i;
-
-		this.setOpacity(1);
-		for (i = childMarkers.length - 1; i >= 0; i--) {
-			m = childMarkers[i];
 
-			m.setLatLng(m._backupPosSpider);
-			delete m._backupPosSpider;
-			m.setZIndexOffset(0);
-
-			L.FeatureGroup.prototype.removeLayer.call(group, m);
-
-			map.removeLayer(m._spiderLeg);
-			delete m._spiderLeg;
-		}
+		this._animationUnspiderfy();
 
 		this._group._spiderfied = null;
 	},
@@ -117,6 +101,27 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 			m._spiderLeg = leg;
 		}
 		this.setOpacity(0.3);
+	},
+
+	_animationUnspiderfy: function () {
+		var group = this._group,
+			map = group._map,
+			childMarkers = this.getAllChildMarkers(),
+			m, i;
+
+		this.setOpacity(1);
+		for (i = childMarkers.length - 1; i >= 0; i--) {
+			m = childMarkers[i];
+
+			m.setLatLng(m._backupPosSpider);
+			delete m._backupPosSpider;
+			m.setZIndexOffset(0);
+
+			L.FeatureGroup.prototype.removeLayer.call(group, m);
+
+			map.removeLayer(m._spiderLeg);
+			delete m._spiderLeg;
+		}
 	}
 } : {
 	//Animated versions here
@@ -205,13 +210,59 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 			}
 
 			setTimeout(function () {
-
-
 				group._animationEnd();
 			}, 250);
 		}, 0);
-	}
+	},
+
+	_animationUnspiderfy: function () {
+		var group = this._group,
+			map = group._map,
+			childMarkers = this.getAllChildMarkers(),
+			svg = L.Browser.svg,
+			m, i, a;
+
+		group._animationStart();
+		
+		//Make us visible and bring the child markers back in
+		this.setOpacity(1);
+		for (i = childMarkers.length - 1; i >= 0; i--) {
+			m = childMarkers[i];
+
+			m.setLatLng(this._latlng);
+			m.setOpacity(0);
+
+			//Animate the spider legs back in
+			if (svg) {
+				a = m._spiderLeg._path.childNodes[0];
+				a.setAttribute('to', a.getAttribute('from'));
+				a.setAttribute('from', 0);
+				a.beginElement();
+
+				a = m._spiderLeg._path.childNodes[1];
+				a.setAttribute('from', 0.5);
+				a.setAttribute('to', 0);
+				a.setAttribute('stroke-opacity', 0);
+				a.beginElement();
+
+				m._spiderLeg._path.setAttribute('stroke-opacity', 0);
+			}
+		}
+
+		setTimeout(function () {
+			for (i = childMarkers.length - 1; i >= 0; i--) {
+				m = childMarkers[i];
+				m.setLatLng(m._backupPosSpider);
+				delete m._backupPosSpider;
+				m.setZIndexOffset(0);
+
+				L.FeatureGroup.prototype.removeLayer.call(group, m);
 
+				map.removeLayer(m._spiderLeg);
+				delete m._spiderLeg;
+			}
+		}, 250);
+	}
 });
 
 

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