mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Merge pull request #123 from Ventero/opacity
Simplify setting element opacity.
This commit is contained in:
commit
2a11c209c4
@ -1013,8 +1013,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
||||
*/
|
||||
setElementOpacity: function( element, opacity, usesAlpha ) {
|
||||
|
||||
var previousFilter,
|
||||
ieOpacity,
|
||||
var ieOpacity,
|
||||
ieFilter;
|
||||
|
||||
element = $.getElement( element );
|
||||
@ -1023,31 +1022,16 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
||||
opacity = Math.round( opacity );
|
||||
}
|
||||
|
||||
if ( $.Browser.opacity ) {
|
||||
element.style.opacity = opacity < 1 ? opacity : "";
|
||||
} else {
|
||||
if ( opacity < 1 ) {
|
||||
element.style.opacity = opacity;
|
||||
} else {
|
||||
element.style.opacity = "";
|
||||
}
|
||||
|
||||
if ( opacity == 1 ) {
|
||||
prevFilter = element.style.filter || "";
|
||||
element.style.filter = prevFilter.replace(/alpha\(.*?\)/g, "");
|
||||
return;
|
||||
}
|
||||
|
||||
ieOpacity = Math.round( 100 * opacity );
|
||||
ieFilter = " alpha(opacity=" + ieOpacity + ") ";
|
||||
|
||||
//TODO: find out why this uses a try/catch instead of a predetermined
|
||||
// routine or at least an if/elseif/else
|
||||
try {
|
||||
if ( element.filters && element.filters.alpha ) {
|
||||
element.filters.alpha.opacity = ieOpacity;
|
||||
ieFilter = "alpha(opacity=" + ieOpacity + ")";
|
||||
element.style.filter = ieFilter;
|
||||
} else {
|
||||
element.style.filter += ieFilter;
|
||||
element.style.filter = "";
|
||||
}
|
||||
} catch ( e ) {
|
||||
element.style.filter += ieFilter;
|
||||
}
|
||||
},
|
||||
|
||||
@ -1630,6 +1614,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
||||
)
|
||||
);
|
||||
|
||||
//determine if this browser supports element.style.opacity
|
||||
$.Browser.opacity = !(
|
||||
$.Browser.vendor == $.BROWSERS.IE &&
|
||||
$.Browser.version < 9
|
||||
);
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user