From 2ccdb9592cd33fdbaa90b7fe81ca41c3a1687486 Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 13 Feb 2013 12:55:22 +0100 Subject: [PATCH] fixed IE8 setOpacity --- src/core/Browser.js | 2 ++ src/dom/DomUtil.js | 10 ++-------- src/layer/tile/TileLayer.js | 28 ++++++++++++++-------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/core/Browser.js b/src/core/Browser.js index 8ce06adf..7902bc17 100644 --- a/src/core/Browser.js +++ b/src/core/Browser.js @@ -14,6 +14,7 @@ android = ua.indexOf('android') !== -1, android23 = ua.search('android [23]') !== -1, ie7 = ie && !document.querySelector && ua.search('msie 7') !== -1, + ie8 = ie && ua.search('msie 8') !== -1, mobile = typeof orientation !== undefined + '', msTouch = window.navigator && window.navigator.msPointerEnabled && @@ -63,6 +64,7 @@ ie: ie, ie6: ie6, ie7: ie7, + ie8: ie8, webkit: webkit, android: android, diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index dfeeb505..5ab2be0f 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -142,18 +142,12 @@ L.DomUtil = { }, setOpacity: function (el, value) { - if ('opacity' in el.style) { el.style.opacity = value; - } else if ('filter' in el.style) { - - var filter = false, - filterName = 'DXImageTransform.Microsoft.Alpha'; - + var filterName = 'alpha'; value = Math.round(value * 100); - - el.style.filter = ' progid:' + filterName + '(opacity=' + value + ')'; + el.style.filter = filterName + '(opacity=' + value + ')'; } }, diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index ed1d6864..2ad1bfe7 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -186,14 +186,20 @@ L.TileLayer = L.Class.extend({ }, _updateOpacity: function () { - if (!L.Browser.ie7) { - L.DomUtil.setOpacity(this._container, this.options.opacity); - } - - // stupid webkit hack to force redrawing of tiles var i, tiles = this._tiles; + if (!L.Browser.ie7 && !L.Browser.ie8) { + L.DomUtil.setOpacity(this._container, this.options.opacity); + } else { + for (i in tiles) { + if (tiles.hasOwnProperty(i)) { + L.DomUtil.setOpacity(tiles[i], this.options.opacity); + } + } + } + + // stupid webkit hack to force redrawing of tiles if (L.Browser.webkit) { for (i in tiles) { if (tiles.hasOwnProperty(i)) { @@ -202,13 +208,6 @@ L.TileLayer = L.Class.extend({ } } - if (L.Browser.ie7) { - for (i in tiles) { - if (tiles.hasOwnProperty(i)) { - tiles[i].style.filter = 'alpha(opacity=' + (this.options.opacity * 100) + ')'; - } - } - } }, @@ -482,8 +481,9 @@ L.TileLayer = L.Class.extend({ _createTile: function () { var tile = this._tileImg.cloneNode(false); tile.onselectstart = tile.onmousemove = L.Util.falseFn; - if (L.Browser.ie7 && this.options.opacity !== undefined) { - tile.style.filter = 'alpha(opacity=' + (this.options.opacity * 100) + ')'; + // in IE7 and IE8 should be set per tile + if ((L.Browser.ie7 || L.Browser.ie8) && this.options.opacity !== undefined) { + L.DomUtil.setOpacity(tile, this.options.opacity); } return tile;