delayed image instance

beta.r3js.org
-=yb4f310 2017-10-27 10:06:22 +02:00
parent c765a5a0d8
commit 4f3f777762
1 changed files with 9 additions and 24 deletions

View File

@ -33,9 +33,17 @@ GameLib.D3.Image = function(
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_IMAGE
GameLib.Component.COMPONENT_IMAGE,
null,
true
);
GameLib.Event.Emit(
GameLib.Event.LOAD_IMAGE,
{
image : this
}
);
};
GameLib.D3.Image.prototype = Object.create(GameLib.D3.API.Image.prototype);
@ -46,29 +54,6 @@ GameLib.D3.Image.prototype.constructor = GameLib.D3.Image;
* @returns {*}
*/
GameLib.D3.Image.prototype.createInstance = function() {
this.instance = document.createElement('img');
this.instance.onload = function() {
GameLib.Event.Emit(
GameLib.Event.IMAGE_INSTANCE_CREATED,
{
image: this
}
);
}.bind(this);
this.instance.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoWEQMQBXD4hQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAABRSURBVGje7c8xDQAwCAAwmA3koA/PU8FB0jpo1nRc9uI4AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBgX0fjEoBa8xN1z4AAAAASUVORK5CYII=';
GameLib.Event.Emit(
GameLib.Event.LOAD_IMAGE,
{
image : this
}
);
GameLib.Component.prototype.createInstance.call(this);
};