Skip to content

Commit

Permalink
Improve performance of re-adding a layer.
Browse files Browse the repository at this point in the history
Previously, when re-adding a layer to its map, the layer would be removed from
the map only to be immediately added back. This prevents the browser from
efficiently updating the display. Now we do the minimal amount of work, while
still guaranteeing that layers appear in the order they were added.
  • Loading branch information
Mike Bostock committed Jul 27, 2010
1 parent da40e9d commit 2a1a5e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Layer.js
Expand Up @@ -187,6 +187,10 @@ po.layer = function(load, unload) {
layer.map = function(x) {
if (!arguments.length) return map;
if (map) {
if (map == x) {
container.parentNode.appendChild(container); // move to end
return layer;
}
map.off("move", move).off("resize", move);
container.parentNode.removeChild(container);
container = levels = null;
Expand Down
2 changes: 1 addition & 1 deletion src/start.js
Expand Up @@ -2,4 +2,4 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){

po.version = "1.0.8"; // semver.org
po.version = "1.0.9"; // semver.org

0 comments on commit 2a1a5e2

Please sign in to comment.