I'm using D3.js to render a graph with nodes containing raster images.
var mainscreenURL = s3_base_url + viewController + "/screenshot.jpeg";
svg.select(".mainScreen").transition().attr("height",0).remove();
svg.append("image").attr("xlink:href", mainscreenURL)
.attr("width", mainScreenW)
.attr("height", mainScreenH)
.attr("x", (w / 2) - (mainScreenW / 2))
.attr("y", (h / 2) - (mainScreenH / 2))
.attr("class", "mainScreen")
.attr("id", viewController)
});
Some of these images are pretty large, so the HTTP requests (made implicitly by the browser) can take a substantial amount of time. I can't cache the images, since they're dynamically generated.
If this were regular HTML, I'd show a placeholder image, and then swap it out for the real thing upon successful completion of the HTTP get request. But since this is SVG, there is no explicit request, and I end up with a nasty broken image which is then replaced with the real thing.
Are there any events I can hook to know when the image is fully loaded?