mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Don't fade between 2 clusters when zooming if they are the same
This commit is contained in:
@@ -229,5 +229,11 @@ L.MarkerCluster = L.Marker.extend({
|
||||
childClusters[k]._recursivelyRemoveChildrenFromMap(depth - 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//Returns true if we are the parent of only one cluster and that cluster is the same as us
|
||||
_isSingleParent: function () {
|
||||
//Don't need to check this._markers as the rest won't work if there are any
|
||||
return this._childClusters.length > 0 && this._childClusters[0]._childCount == this._childCount;
|
||||
}
|
||||
});
|
||||
@@ -430,9 +430,14 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
|
||||
c = startingClusters[i];
|
||||
startPos = c.getLatLng();
|
||||
|
||||
//Fade out old cluster
|
||||
c.setOpacity(0);
|
||||
c._recursivelyAddChildrenToMap(startPos, depth, bounds);
|
||||
if (c._isSingleParent()) {
|
||||
L.FeatureGroup.prototype.removeLayer.call(this, c);
|
||||
c._recursivelyAddChildrenToMap(null, depth, bounds);
|
||||
} else {
|
||||
//Fade out old cluster
|
||||
c.setOpacity(0);
|
||||
c._recursivelyAddChildrenToMap(startPos, depth, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove all markers that aren't visible any more
|
||||
@@ -484,7 +489,13 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
|
||||
c._recursivelyAnimateChildrenIn(this._map.latLngToLayerPoint(c.getLatLng()).round(), depth);
|
||||
|
||||
if (bounds.contains(c._latlng)) { //Add the new cluster but have it be hidden (so it gets animated, display=none stops transition)
|
||||
c.setOpacity(0);
|
||||
|
||||
if (c._isSingleParent()) { //If we are the same as our parent, don't do an animation, just immediately appear
|
||||
c.setOpacity(1);
|
||||
c._recursivelyRemoveChildrenFromMap(depth);
|
||||
} else {
|
||||
c.setOpacity(0);
|
||||
}
|
||||
c._addToMap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user