Totally steal @javisantana's fix for IE TileLayer opacity ;)

This commit is contained in:
danzel 2013-02-15 10:33:54 +13:00
parent 513c6ca4cd
commit 4ffc982372
2 changed files with 17 additions and 3 deletions

View File

@ -7,6 +7,7 @@
var ie = !!window.ActiveXObject, var ie = !!window.ActiveXObject,
ie6 = ie && !window.XMLHttpRequest, ie6 = ie && !window.XMLHttpRequest,
ie7 = ie && !document.querySelector, ie7 = ie && !document.querySelector,
ielt9 = ie && !document.addEventListener,
// 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(),
@ -63,6 +64,7 @@
ie: ie, ie: ie,
ie6: ie6, ie6: ie6,
ie7: ie7, ie7: ie7,
ielt9: ielt9,
webkit: webkit, webkit: webkit,
android: android, android: android,

View File

@ -186,12 +186,20 @@ L.TileLayer = L.Class.extend({
}, },
_updateOpacity: function () { _updateOpacity: function () {
L.DomUtil.setOpacity(this._container, this.options.opacity);
// stupid webkit hack to force redrawing of tiles
var i, var i,
tiles = this._tiles; tiles = this._tiles;
if (L.Browser.ielt9) {
for (i in tiles) {
if (tiles.hasOwnProperty(i)) {
L.DomUtil.setOpacity(tiles[i], this.options.opacity);
}
}
} else {
L.DomUtil.setOpacity(this._container, this.options.opacity);
}
// stupid webkit hack to force redrawing of tiles
if (L.Browser.webkit) { if (L.Browser.webkit) {
for (i in tiles) { for (i in tiles) {
if (tiles.hasOwnProperty(i)) { if (tiles.hasOwnProperty(i)) {
@ -471,6 +479,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.ielt9 && this.options.opacity !== undefined) {
L.DomUtil.setOpacity(tile, this.options.opacity);
}
return tile; return tile;
}, },