From c5ad9b25bf67d381e217a0183448f74bd20b584d Mon Sep 17 00:00:00 2001 From: zakharov-aa Date: Wed, 28 Sep 2016 09:40:28 +0300 Subject: [PATCH] IE8 fix for tileSources type: 'image' --- src/imagetilesource.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/imagetilesource.js b/src/imagetilesource.js index 3562bf50..5ae9e869 100644 --- a/src/imagetilesource.js +++ b/src/imagetilesource.js @@ -72,6 +72,13 @@ $.TileSource.apply(this, [options]); }; + + /* IE8 fix for tileSources type: 'image' */ + $.getNatural = function (DOMelement) { + var img = new Image(); + img.src = DOMelement.src; + return { width: img.width, height: img.height }; + }; $.extend($.ImageTileSource.prototype, $.TileSource.prototype, /** @lends OpenSeadragon.ImageTileSource.prototype */{ /** @@ -114,8 +121,8 @@ } $.addEvent(image, 'load', function () { - _this.width = image.naturalWidth; - _this.height = image.naturalHeight; + _this.width = $.getNatural(image).width; + _this.height = $.getNatural(image).height; _this.aspectRatio = _this.width / _this.height; _this.dimensions = new $.Point(_this.width, _this.height); _this._tileWidth = _this.width; @@ -202,8 +209,8 @@ _buildLevels: function () { var levels = [{ url: this._image.src, - width: this._image.naturalWidth, - height: this._image.naturalHeight + width: $.getNatural(this._image).width, + height: $.getNatural(this._image).height }]; if (!this.buildPyramid || !$.supportsCanvas || !this.useCanvas) {