Update change log, bump to 0.4.0 and rebuild

This commit is contained in:
danzel
2013-12-19 16:27:52 +13:00
parent f0b1618e07
commit 20cf8edd0d
4 changed files with 49 additions and 20 deletions

View File

@@ -5,6 +5,17 @@ Leaflet.markercluster
## Master ## Master
##0.4 (2012-12-19)
### Improvements
* Fix Quick Zoom in/out causing everything to disappear in Firefox (Reported by [@paulovieira](https://github.com/paulovieira)) [#140](https://github.com/Leaflet/Leaflet.markercluster/issues/140)
* Slow the expand/contract animation down from 200ms to 300ms
### Bugfixes
* Fix some cases zoomToShowLayer wouldn't work (Reported by [@absemetov](https://github.com/absemetov)) [#203](https://github.com/Leaflet/Leaflet.markercluster/issues/203) [#228](https://github.com/Leaflet/Leaflet.markercluster/issues/228) [#286](https://github.com/Leaflet/Leaflet.markercluster/issues/286)
##0.3 (2013-12-18) ##0.3 (2013-12-18)
### Improvements ### Improvements

View File

@@ -53,6 +53,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
this._needsRemoving = []; //Markers removed while we aren't on the map need to be kept track of this._needsRemoving = []; //Markers removed while we aren't on the map need to be kept track of
//The bounds of the currently shown area (from _getExpandedVisibleBounds) Updated on zoom/move //The bounds of the currently shown area (from _getExpandedVisibleBounds) Updated on zoom/move
this._currentShownBounds = null; this._currentShownBounds = null;
this._queue = [];
}, },
addLayer: function (layer) { addLayer: function (layer) {
@@ -381,14 +383,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
} }
}; };
if (layer._icon) { if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) {
callback(); callback();
} else if (layer.__parent._zoom < this._map.getZoom()) { } else if (layer.__parent._zoom < this._map.getZoom()) {
//Layer should be visible now but isn't on screen, just pan over to it //Layer should be visible now but isn't on screen, just pan over to it
this._map.on('moveend', showMarker, this); this._map.on('moveend', showMarker, this);
if (!layer._icon) { this._map.panTo(layer.getLatLng());
this._map.panTo(layer.getLatLng());
}
} else { } else {
this._map.on('moveend', showMarker, this); this._map.on('moveend', showMarker, this);
this.on('animationend', showMarker, this); this.on('animationend', showMarker, this);
@@ -791,8 +791,28 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
return; return;
}, },
//Enqueue code to fire after the marker expand/contract has happened
_enqueue: function (fn) {
this._queue.push(fn);
if (!this._queueTimeout) {
this._queueTimeout = setTimeout(L.bind(this._processQueue, this), 300);
}
},
_processQueue: function () {
for (var i = 0; i < this._queue.length; i++) {
this._queue[i].call(this);
}
this._queue.length = 0;
clearTimeout(this._queueTimeout);
this._queueTimeout = null;
},
//Merge and split any existing clusters that are too big or small //Merge and split any existing clusters that are too big or small
_mergeSplitClusters: function () { _mergeSplitClusters: function () {
//Incase we are starting to split before the animation finished
this._processQueue();
if (this._zoom < this._map._zoom && this._currentShownBounds.contains(this._getExpandedVisibleBounds())) { //Zoom in, split if (this._zoom < this._map._zoom && this._currentShownBounds.contains(this._getExpandedVisibleBounds())) { //Zoom in, split
this._animationStart(); this._animationStart();
//Remove clusters now off screen //Remove clusters now off screen
@@ -875,9 +895,8 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
this.fire('animationend'); this.fire('animationend');
}, },
_animationZoomIn: function (previousZoomLevel, newZoomLevel) { _animationZoomIn: function (previousZoomLevel, newZoomLevel) {
var me = this, var bounds = this._getExpandedVisibleBounds(),
bounds = this._getExpandedVisibleBounds(), fg = this._featureGroup,
fg = this._featureGroup,
i; i;
//Add all children of current clusters to map and remove those clusters from map //Add all children of current clusters to map and remove those clusters from map
@@ -913,7 +932,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
this._forceLayout(); this._forceLayout();
//Update opacities //Update opacities
me._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel); this._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel);
//TODO Maybe? Update markers in _recursivelyBecomeVisible //TODO Maybe? Update markers in _recursivelyBecomeVisible
fg.eachLayer(function (n) { fg.eachLayer(function (n) {
if (!(n instanceof L.MarkerCluster) && n._icon) { if (!(n instanceof L.MarkerCluster) && n._icon) {
@@ -922,21 +941,20 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
}); });
//update the positions of the just added clusters/markers //update the positions of the just added clusters/markers
me._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function (c) { this._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function (c) {
c._recursivelyRestoreChildPositions(newZoomLevel); c._recursivelyRestoreChildPositions(newZoomLevel);
}); });
//Remove the old clusters and close the zoom animation //Remove the old clusters and close the zoom animation
this._enqueue(function () {
setTimeout(function () {
//update the positions of the just added clusters/markers //update the positions of the just added clusters/markers
me._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) { this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function (c) {
fg.removeLayer(c); fg.removeLayer(c);
c.setOpacity(1); c.setOpacity(1);
}); });
me._animationEnd(); this._animationEnd();
}, 200); });
}, },
_animationZoomOut: function (previousZoomLevel, newZoomLevel) { _animationZoomOut: function (previousZoomLevel, newZoomLevel) {
@@ -961,7 +979,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
//TODO: Maybe use the transition timing stuff to make this more reliable //TODO: Maybe use the transition timing stuff to make this more reliable
//When the animations are done, tidy up //When the animations are done, tidy up
setTimeout(function () { this._enqueue(function () {
//This cluster stopped being a cluster before the timeout fired //This cluster stopped being a cluster before the timeout fired
if (cluster._childCount === 1) { if (cluster._childCount === 1) {
@@ -975,7 +993,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
}); });
} }
me._animationEnd(); me._animationEnd();
}, 200); });
}, },
_animationAddLayer: function (layer, newCluster) { _animationAddLayer: function (layer, newCluster) {
var me = this, var me = this,
@@ -992,12 +1010,12 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng())); layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng()));
layer.setOpacity(0); layer.setOpacity(0);
setTimeout(function () { this._enqueue(function () {
fg.removeLayer(layer); fg.removeLayer(layer);
layer.setOpacity(1); layer.setOpacity(1);
me._animationEnd(); me._animationEnd();
}, 200); });
} else { //Just became a cluster } else { //Just became a cluster
this._forceLayout(); this._forceLayout();

View File

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "leaflet.markercluster", "name": "leaflet.markercluster",
"version": "0.3.0", "version": "0.4.0",
"description": "Provides Beautiful Animated Marker Clustering functionality for Leaflet", "description": "Provides Beautiful Animated Marker Clustering functionality for Leaflet",
"dependencies": { "dependencies": {
"leaflet": "~0.7.1" "leaflet": "~0.7.1"