Permalink
Browse files

Treat null `url` for `po.image` as empty tiles.

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...
1 parent 1754c96 commit 5aa27172262d4ac6575095918313a64827c52472 @jasondavies jasondavies committed Nov 27, 2010
Showing with 81 additions and 69 deletions.
  1. +12 −6 polymaps.js
  2. +57 −57 polymaps.min.js
  3. +11 −5 src/Image.js
  4. +1 −1 src/Url.js
View
@@ -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) {
@@ -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);
Oops, something went wrong.

0 comments on commit 5aa2717

Please sign in to comment.