Skip to content

Commit 36d35b1

Browse files
committed
Use naturalWidth to check image load complete.
Browsers other than IE erroneously report a failed load as complete. Signed-off-by: Grant Skinner <info@gskinner.com>
1 parent a09a9c5 commit 36d35b1

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/easeljs/display/Bitmap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ this.createjs = this.createjs||{};
184184
p.getBounds = function() {
185185
var rect = this.DisplayObject_getBounds();
186186
if (rect) { return rect; }
187-
var o = this.sourceRect || this.image;
188-
var hasContent = (this.image && (this.image.complete || this.image.getContext || this.image.readyState >= 2));
187+
var image = this.image, o = this.sourceRect || image;
188+
var hasContent = (image && (image.naturalWidth || image.getContext || image.readyState >= 2));
189189
return hasContent ? this._rectangle.setValues(0, 0, o.width, o.height) : null;
190190
};
191191

src/easeljs/display/Graphics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ this.createjs = this.createjs||{};
19791979
* @return {Fill} Returns this Fill object for chaining or assignment.
19801980
*/
19811981
p.bitmap = function(image, repetition) {
1982-
if (image.complete || image.getContext || image.readyState >= 2) {
1982+
if (image.naturalWidth || image.getContext || image.readyState >= 2) {
19831983
var o = this.style = Graphics._ctx.createPattern(image, repetition || "");
19841984
o.props = {image: image, repetition: repetition, type: "bitmap"};
19851985
}

src/easeljs/display/SpriteSheet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ this.createjs = this.createjs||{};
437437
img.src = src;
438438
}
439439
a.push(img);
440-
if (!img.getContext && !img.complete) {
440+
if (!img.getContext && !img.naturalWidth) {
441441
this._loadCount++;
442442
this.complete = false;
443443
(function(o) { img.onload = function() { o._handleImageLoad(); } })(this);

src/easeljs/display/SpriteStage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ this.createjs = this.createjs||{};
782782
* @protected
783783
**/
784784
p._setupImageTexture = function(ctx, image) {
785-
if (image && (image.complete || image.getContext || image.readyState >= 2)) {
785+
if (image && (image.naturalWidth || image.getContext || image.readyState >= 2)) {
786786
// Create and use a new texture for this image if it doesn't already have one:
787787
var texture = image.__easeljs_texture;
788788
if (!texture) {

0 commit comments

Comments
 (0)