diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d42ce78..e4bb3620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -146,6 +146,7 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i * Fixed a bug that could cause false `mousemove` events on click in Chrome (by [@stsydow](https://github.com/stsydow)). [#757](https://github.com/CloudMade/Leaflet/pull/757) * Fixed a bug in IE6-8 where adding fill or stroke on vector layers after initialization with `setStyle` would break the map. [#641](https://github.com/CloudMade/Leaflet/issues/641) * Fixed a bug that broke Leaflet for websites that had XHTML content-type header set (by [lars-sh](https://github.com/lars-sh)). [#801](https://github.com/CloudMade/Leaflet/pull/801) + * Fixed a bug with setOpacity in IE where it would not work correctly if used more than once on the same element (by [@ajbeaven](https://github.com/ajbeaven)). [#827](https://github.com/CloudMade/Leaflet/pull/827) #### Mobile browser bugfixes diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index ca85b8c2..55d8f282 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -106,29 +106,25 @@ L.DomUtil = { }, setOpacity: function (el, value) { + if ('opacity' in el.style) { el.style.opacity = value; + } else if (L.Browser.ie) { + var filter = false, - prefix = 'DXImageTransform.Microsoft.', - filterName = '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(prefix + filterName); } catch (e) { } - if (!filter) try { filter = el.filters.item(filterName); } catch (e) { } + try { filter = el.filters.item(filterName); } catch (e) {} value = Math.round(value * 100); - if (value === 100) { - if (filter) { - filter.Enabled = false; - } + + if (filter) { + filter.Enabled = (value === 100); + filter.Opacity = value; } else { - if (filter) { - filter.Enabled = true; - filter.Opacity = value; - } else { - el.style.filter += ' progid:' + prefix + filterName + '(opacity=' + value + ')'; - } + el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')'; } } },