[Pkg-javascript-commits] [leaflet-markercluster] 201/219: Test for unspiderfied event
Jonas Smedegaard
dr at jones.dk
Sat May 7 09:39:35 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 de4d3321c62ba5cd1165b11c5f54c52e6cb8b369
Author: danzel <danzel at localhost.geek.nz>
Date: Tue Dec 22 10:36:41 2015 +1300
Test for unspiderfied event
---
spec/suites/spiderfySpec.js | 30 ++++++++++++++++++++++++++++++
src/MarkerCluster.Spiderfier.js | 13 ++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/spec/suites/spiderfySpec.js b/spec/suites/spiderfySpec.js
index b34e5a9..ff417d7 100644
--- a/spec/suites/spiderfySpec.js
+++ b/spec/suites/spiderfySpec.js
@@ -241,6 +241,36 @@
});
+ it('fires unspiderfied event on unspiderfy', function (done) {
+
+ group = new L.MarkerClusterGroup();
+
+ var marker = new L.Marker([1.5, 1.5]);
+ var marker2 = new L.Marker([1.5, 1.5]);
+
+ group.addLayers([marker, marker2]);
+ map.addLayer(group);
+
+ marker.__parent.spiderfy();
+
+ clock.tick(1000);
+
+ // Add event listener
+ group.on('unspiderfied', function (event) {
+ expect(event.target).to.be(group);
+ expect(event.cluster).to.be.a(L.Marker);
+ expect(event.markers[1]).to.be(marker);
+ expect(event.markers[0]).to.be(marker2);
+
+ done();
+ });
+
+ marker.__parent.unspiderfy();
+
+ clock.tick(1000);
+
+ });
+
it('does not leave class "leaflet-cluster-anim" on mapPane when group is removed while spiderfied', function () {
group = new L.MarkerClusterGroup();
diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index 18a71c7..6b2f649 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -114,7 +114,10 @@ L.MarkerCluster.include({
}
}
- group.fire('unspiderfied');
+ group.fire('unspiderfied', {
+ cluster: this,
+ markers: childMarkers
+ });
group._spiderfied = null;
}
});
@@ -265,7 +268,8 @@ L.MarkerCluster.include({
},
_animationUnspiderfy: function (zoomDetails) {
- var group = this._group,
+ var me = this,
+ group = this._group,
map = group._map,
fg = group._featureGroup,
thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(this._latlng, zoomDetails.zoom, zoomDetails.center) : map.latLngToLayerPoint(this._latlng),
@@ -346,7 +350,10 @@ L.MarkerCluster.include({
delete m._spiderLeg;
}
group._animationEnd();
- group.fire('unspiderfied');
+ group.fire('unspiderfied', {
+ cluster: me,
+ markers: childMarkers
+ });
}, 200);
}
});
--
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