sort portal layers so they're above links/fields - but only when there's not that many

a lot of redrawing occurs when sorting portals - so only ordering when there's a low number keeps things reasonably fast
This commit is contained in:
Jon Atkins 2013-08-27 16:31:45 +01:00
parent cae60c0843
commit 563258a897

View File

@ -4,6 +4,10 @@
window.Render = function() {
// below this many portals displayed, we reorder the SVG at the end of the render pass to put portals above fields/links
this.LOW_PORTAL_COUNT = 350;
}
@ -93,6 +97,19 @@ window.Render.prototype.endRenderPass = function() {
}
}
// reorder portals to be after links/fields, but only if the number is low
if (Object.keys(window.portals).length <= this.LOW_PORTAL_COUNT) {
for (var i in window.portalsLayers) {
var layer = window.portalsLayers[i];
if (window.map.hasLayer(layer)) {
layer.eachLayer (function(p) {
p.bringToFront();
});
}
}
}
this.isRendering = false;
}