Use feature detection instead of browser sniffing for opacity, #796

This commit is contained in:
Vladimir Agafonkin 2012-07-12 10:31:21 +03:00
parent 2a7e49bfe3
commit 4edfaee008
4 changed files with 13 additions and 16 deletions

11
dist/leaflet-src.js vendored
View File

@ -374,6 +374,7 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
}());
L.Browser = {
ua: ua,
ie: ie,
ie6: ie6,
webkit: webkit,
@ -715,10 +716,10 @@ L.DomUtil = {
},
setOpacity: function (el, value) {
if (L.Browser.ie) {
el.style.filter += value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : '';
} else {
if ('opacity' in el.style) {
el.style.opacity = value;
} else if (L.Browser.ie) {
el.style.filter += value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : '';
}
},
@ -3319,6 +3320,10 @@ L.FeatureGroup = L.LayerGroup.extend({
includes: L.Mixin.Events,
addLayer: function (layer) {
if (this._layers[L.Util.stamp(layer)]) {
return this;
}
layer.on('click dblclick mouseover mouseout', this._propagateEvent, this);
L.LayerGroup.prototype.addLayer.call(this, layer);

2
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -39,19 +39,11 @@
div = null;
return supported;
}()),
ieversion = ie && (function () {
var re = new RegExp("msie ([0-9]{1,}[\\.0-9]{0,})");
if (re.exec(ua) !== null) {
return parseFloat(RegExp.$1);
}
return null;
}());
}());
L.Browser = {
ua: ua,
ie: ie,
iefilter: ie && ieversion < 9,
ie6: ie6,
webkit: webkit,
gecko: gecko,

View File

@ -106,10 +106,10 @@ L.DomUtil = {
},
setOpacity: function (el, value) {
if (L.Browser.iefilter) {
el.style.filter += value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : '';
} else {
if ('opacity' in el.style) {
el.style.opacity = value;
} else if (L.Browser.ie) {
el.style.filter += value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : '';
}
},