mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Remove onLoad workaround, and use #attach('load') instead of #onLoad internally.
This commit is contained in:
parent
523f5c1789
commit
50f810a1ad
1 changed files with 2 additions and 7 deletions
|
@ -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;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue