[Pkg-javascript-commits] [leaflet-markercluster] 118/219: Improved zoomToShowLayer with callback check

Jonas Smedegaard dr at jones.dk
Sat May 7 09:39:22 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 60360b13b1be34c2d36921d01a3d71b6552658b2
Author: ghybs <ghybs at users.noreply.github.com>
Date:   Fri Oct 9 13:36:28 2015 +0400

    Improved zoomToShowLayer with callback check
    
    Following issue #503, slightly improved `zoomToShowLayer` to check that a proper callback function is passed. Also slightly simplified the event binding on `parent.spiderfy()` (using directly `this.once` instead of manually unbinding it).
---
 src/MarkerClusterGroup.js | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 2a19e7e..e6245f6 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -416,6 +416,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 	//Zoom down to show the given layer (spiderfying if necessary) then calls the callback
 	zoomToShowLayer: function (layer, callback) {
+		
+		if (typeof callback !== 'function') {
+			callback = function () {};
+		}
 
 		var showMarker = function () {
 			if ((layer._icon || layer.__parent._icon) && !this._inZoomAnimation) {
@@ -425,12 +429,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 				if (layer._icon) {
 					callback();
 				} else if (layer.__parent._icon) {
-					var afterSpiderfy = function () {
-						this.off('spiderfied', afterSpiderfy, this);
-						callback();
-					};
-
-					this.on('spiderfied', afterSpiderfy, this);
+					this.once('spiderfied', callback, this);
 					layer.__parent.spiderfy();
 				}
 			}

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