mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Prevent double execution of onLoad event on Raster.
This commit is contained in:
parent
e87307af41
commit
affb44e0dd
1 changed files with 9 additions and 7 deletions
|
@ -274,11 +274,18 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
var that = this,
|
var that = this,
|
||||||
// src can be an URL or a DOM ID to load the image from
|
// src can be an URL or a DOM ID to load the image from
|
||||||
image = document.getElementById(src) || new Image();
|
image = document.getElementById(src) || new Image();
|
||||||
|
|
||||||
function loaded() {
|
function loaded() {
|
||||||
that.fire('load');
|
that.fire('load');
|
||||||
if (that._project.view)
|
if (that._project.view)
|
||||||
that._project.view.draw(true);
|
that._project.view.draw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image.width && image.height) {
|
||||||
|
// Fire load event delayed, so behavior is the same as when it's
|
||||||
|
// actually loaded and we give the code time to install event
|
||||||
|
setTimeout(loaded, 0);
|
||||||
|
} else if (!image.src) {
|
||||||
// Trigger the onLoad event on the image once it's loaded
|
// Trigger the onLoad event on the image once it's loaded
|
||||||
DomEvent.add(image, {
|
DomEvent.add(image, {
|
||||||
load: function() {
|
load: function() {
|
||||||
|
@ -286,11 +293,6 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
loaded();
|
loaded();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (image.width && image.height) {
|
|
||||||
// Fire load event delayed, so behavior is the same as when it's
|
|
||||||
// actually loaded and we give the code time to install event
|
|
||||||
setTimeout(loaded, 0);
|
|
||||||
} else if (!image.src) {
|
|
||||||
image.src = src;
|
image.src = src;
|
||||||
}
|
}
|
||||||
this.setImage(image);
|
this.setImage(image);
|
||||||
|
|
Loading…
Reference in a new issue