fixed setOpacity in IE7 and IE8

This commit is contained in:
javi 2013-02-12 18:44:10 +01:00
parent c2379a335d
commit 97ce8187fd
3 changed files with 18 additions and 11 deletions

View File

@ -6,7 +6,6 @@
var ie = !!window.ActiveXObject, var ie = !!window.ActiveXObject,
ie6 = ie && !window.XMLHttpRequest, ie6 = ie && !window.XMLHttpRequest,
ie7 = ie && !document.querySelector,
// terrible browser detection to work around Safari / iOS / Android browser bugs // terrible browser detection to work around Safari / iOS / Android browser bugs
ua = navigator.userAgent.toLowerCase(), ua = navigator.userAgent.toLowerCase(),
@ -14,6 +13,7 @@
chrome = ua.indexOf('chrome') !== -1, chrome = ua.indexOf('chrome') !== -1,
android = ua.indexOf('android') !== -1, android = ua.indexOf('android') !== -1,
android23 = ua.search('android [23]') !== -1, android23 = ua.search('android [23]') !== -1,
ie7 = ie && !document.querySelector && ua.search('msie 7') !== -1,
mobile = typeof orientation !== undefined + '', mobile = typeof orientation !== undefined + '',
msTouch = window.navigator && window.navigator.msPointerEnabled && msTouch = window.navigator && window.navigator.msPointerEnabled &&

View File

@ -151,17 +151,9 @@ L.DomUtil = {
var filter = false, var filter = false,
filterName = 'DXImageTransform.Microsoft.Alpha'; filterName = 'DXImageTransform.Microsoft.Alpha';
// filters collection throws an error if we try to retrieve a filter that doesn't exist
try { filter = el.filters.item(filterName); } catch (e) {}
value = Math.round(value * 100); value = Math.round(value * 100);
if (filter) { el.style.filter = ' progid:' + filterName + '(opacity=' + value + ')';
filter.Enabled = (value !== 100);
filter.Opacity = value;
} else {
el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';
}
} }
}, },

View File

@ -186,7 +186,9 @@ L.TileLayer = L.Class.extend({
}, },
_updateOpacity: function () { _updateOpacity: function () {
L.DomUtil.setOpacity(this._container, this.options.opacity); if (!L.Browser.ie7) {
L.DomUtil.setOpacity(this._container, this.options.opacity);
}
// stupid webkit hack to force redrawing of tiles // stupid webkit hack to force redrawing of tiles
var i, var i,
@ -199,6 +201,15 @@ 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) + ')';
}
}
}
}, },
_initContainer: function () { _initContainer: function () {
@ -471,6 +482,10 @@ L.TileLayer = L.Class.extend({
_createTile: function () { _createTile: function () {
var tile = this._tileImg.cloneNode(false); var tile = this._tileImg.cloneNode(false);
tile.onselectstart = tile.onmousemove = L.Util.falseFn; tile.onselectstart = tile.onmousemove = L.Util.falseFn;
if (L.Browser.ie7 && this.options.opacity !== undefined) {
tile.style.filter = 'alpha(opacity=' + (this.options.opacity * 100) + ')';
}
return tile; return tile;
}, },