2011-09-14 131 views
0

我试图使用Humanized Messages jQuery插件,我遇到了一些麻烦。即使我将移动鼠标/最后的超时会触发消息也不会消失。我认为这与jQuery的编码风格/最新版本有关。我重写了我自己的编码风格的插件,并检查了jQuery文档 - 一切都取决于鼻烟。不透明度动画到特定值

的问题,我发现,它这个代码(其中humanMsg.msgOpacity0.8)的动画不透明度为“0.800000011920929”,而不是简单的“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 }) }); 
     }); 
    } 
}); 

为什么会出现这种情况,如何能我阻止它?我正在运行Chrome 13.0.782.220。

回答

0

我已经决定这一个欺骗:

if (jQuery('#'+humanMsg.msgID).css('opacity') >= (humanMsg.msgOpacity - 0.05)) 
{ 
    jQuery('#'+humanMsg.msgID).animate({ opacity: 0 }, 500, function() { jQuery(this).hide() }); 
}