Skip to content

Commit

Permalink
IE11 svg image fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
justinharrell committed Sep 19, 2017
1 parent bc6330d commit c9edcbe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/network/CachedImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,28 @@ class CachedImage {
this.width = w;
this.height = h;

var h2 = Math.floor(h/2);
var h4 = Math.floor(h/4);
var h8 = Math.floor(h/8);
var h16 = Math.floor(h/16);

var w2 = Math.floor(w/2);
var w4 = Math.floor(w/4);
var w8 = Math.floor(w/8);
var w16 = Math.floor(w/16);

// Make canvas as small as possible
this.canvas.width = 3*w/4;
this.canvas.height = h/2;
this.canvas.width = 3*w4;
this.canvas.height = h2;

// Coordinates and sizes of images contained in the canvas
// Values per row: [top x, left y, width, height]

this.coordinates = [
[ 0 , 0 , w/2 , h/2],
[ w/2 , 0 , w/4 , h/4],
[ w/2 , h/4, w/8 , h/8],
[ 5*w/8, h/4, w/16, h/16]
[ 0 , 0 , w2 , h2],
[ w2 , 0 , w4 , h4],
[ w2 , h4, w8 , h8],
[ 5*w8, h4, w16, h16]
];

this._fillMipMap();
Expand Down Expand Up @@ -152,7 +163,7 @@ class CachedImage {
// naturalHeight. These give the true size of the image. If it failed
// to load, either of these should be zero.

if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0 && img.IEFix!==true) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions lib/network/Images.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Images {
document.body.appendChild(imageToCache);
imageToCache.width = imageToCache.offsetWidth;
imageToCache.height = imageToCache.offsetHeight;
imageToCache.IEFix = true;
document.body.removeChild(imageToCache);
}
}
Expand Down

0 comments on commit c9edcbe

Please sign in to comment.