Trouble getting opacity to animate to specific value
I'm trying to use the Humanized Messages jQuery plugin and I'm having some trouble with it. The message would not fade out at all even though I would move the mouse/the final timeout would fire. I thought it was something to do with the coding style/the latest version of jQuery. I rewrote the plugin to my own coding style and checked the jQuery documentation - e开发者_开发技巧verything is up to snuff.
The problem, I found out, it that this code (where humanMsg.msgOpacity
is 0.8
) is animating the opacity to "0.800000011920929" instead of simply "0.8":
jQuery('#'+humanMsg.msgID).show().animate({ opacity: humanMsg.msgOpacity}, 200, function(){
jQuery('#'+humanMsg.logID).show().children('ul').prepend('<li>'+msg+'</li>').children('li:first').slideDown(200);
if (jQuery('#'+humanMsg.logID+' ul').css('display') == 'none')
{
jQuery('#'+humanMsg.logID+' p').animate({ bottom: 40 }, 200, 'linear', function(){
jQuery(this).animate({ bottom: 0 }, 300, 'easeOutBounce', function() { jQuery(this).css({ bottom: 0 }) });
});
}
});
Why is this happening and how can I prevent it? I'm running Chrome 13.0.782.220.
I've decided to cheat with this one:
if (jQuery('#'+humanMsg.msgID).css('opacity') >= (humanMsg.msgOpacity - 0.05))
{
jQuery('#'+humanMsg.msgID).animate({ opacity: 0 }, 500, function() { jQuery(this).hide() });
}
精彩评论