多くの人が知っているように、アルファ透明度を使用してPNGをアニメーション化することは<IE8
あまりうまく機能しません。したがって、で不透明度のアニメーション化を無効にし<IE8
ます。
私がこのようなことをしているのを見ることができる唯一の方法は、これをすることです:
HTML
<!--[if lt IE 8]>
<script type="text/javascript">
var browserUnsupported = true;
</script>
<![endif]-->
JAVASCRIPT
// Test if the browser is supported
if(browserUnsupported){
// Hide the element
$('#test').hide();
}else{
// Fade out the element and then hide it
$('#test').animate({
opacity:0
},200,function(){
$(this).hide();
})
}
// Once the animation has completed, continue
setTimeout(function(){
// This will execute once the animation has completed
// We cannot use the callback in case the browser is unsupported
// and the animate function has not been used
},200);
しかし、これはかなり長い修正です。特に、何かをアニメーション化するたびに、これを実行する必要があることを考慮した場合はなおさらです。
誰かがより良い代替案を思い付くことができますか?
Internet Explorer 8以下で不透明度のアニメーション化を無効にできますか?ハッキングがある場合は、jQueryをローカルに保存せず、GoogleCDNからロードすることを考慮してください。これが唯一のオプションであっても、jQueryソースを変更するつもりはありません。
アップデート
私はブラウザのバージョンを検出するためのより良い方法を探していません。上記のコードは、説明のみを目的としています。私が知りたいのは、jQueryによってアニメーション化する不透明度を制御できる方法があるかどうかです。または、条件があればアニメーション化するより良い方法はありますか?そうでない場合はアニメーション化しないでください。
アップデート
このようなもの(テストされていません):
function myAnimate(styles,duration,easing,callback){
// Get the selected element
var element = this.elements;
if($.browser.msie && $.browser.version<8){
delete options.opacity;
}
// Call the animation method
element.animate(options,duration,easing,callback);
}