Skip to content

Commit

Permalink
Treat null url for po.image as empty tiles.
Browse files Browse the repository at this point in the history
Instead of setting the image URL to `about:blank`, no image URL is set
when `null` URLs are detected.  This appears to be slightly faster than
using `about:blank`, at least in Firefox.  I've updated `po.image`'s
`repeat` accordingly.
  • Loading branch information
jasondavies committed Nov 27, 2010
1 parent 1754c96 commit 5aa2717
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 69 deletions.
18 changes: 12 additions & 6 deletions polymaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ po.url = function(template) {
column = c.column % max;
if (column < 0) column += max;
} else if ((column < 0) || (column >= max)) {
return "about:blank";
return null;
}
return template.replace(/{(.)}/g, function(s, v) {
switch (v) {
Expand Down Expand Up @@ -1110,13 +1110,19 @@ po.image = function() {

if (typeof url == "function") {
element.setAttribute("opacity", 0);
tile.request = po.queue.image(element, url(tile), function(img) {
delete tile.request;
var tileUrl = url(tile);
if (tileUrl !== null) {
tile.request = po.queue.image(element, tileUrl, function(img) {
delete tile.request;
tile.ready = true;
tile.img = img;
element.removeAttribute("opacity");
image.dispatch({type: "load", tile: tile});
});
} else {
tile.ready = true;
tile.img = img;
element.removeAttribute("opacity");
image.dispatch({type: "load", tile: tile});
});
}
} else {
tile.ready = true;
if (url) element.setAttributeNS(po.ns.xlink, "href", url);
Expand Down
Loading

0 comments on commit 5aa2717

Please sign in to comment.