Remove onLoad workaround, and use #attach('load') instead of #onLoad internally.

This commit is contained in:
Jürg Lehni 2012-12-02 21:08:57 -08:00
parent 523f5c1789
commit 50f810a1ad

View file

@ -272,18 +272,13 @@ new function() {
// http://www.w3.org/TR/SVG/struct.html#ImageElement
image: function (svg) {
var raster = new Raster(getValue(svg, 'href'));
// TODO: for some reason Raster#onLoad is being fired twice,
// as a workaround work with alreadyLoaded variable
var alreadyLoaded = false;
raster.onLoad = function() {
if (alreadyLoaded) return;
raster.attach('load', function() {
var size = getSize(svg, 'width', 'height');
this.setSize(size);
// Since x and y start from the top left of an image, add
// half of its size:
this.translate(getPoint(svg, 'x', 'y').add(size.divide(2)));
alreadyLoaded = true;
};
});
return raster;
},