2011-09-14 133 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() }); 
}