2013-03-24 52 views
1

當光標懸停時,我創建一個div動畫。
這是使用mouseover(jquery)。
現在的問題是,該div上的文本會中斷動畫,因爲光標不再與div直接接觸。文本中斷鼠標懸停

我該如何解決這個問題?

//navi is the div. 

    $("#navi").mouseover(function(){ 
     $("#navi").stop(); 
     $("#navi").animate({width:'200px'},{queue: false,easing:"easeOutBounce",duration:1200}); 
    }); 

相同的代碼在text-div上。

你可以在這裏http://jsfiddle.net/rSQaP/17/

測試它只是嘗試將鼠標放置及移出而紅股利的動畫。 動畫將受到藍色div上的鼠標懸停動作的影響。

+0

請問碼? :)(http://stackoverflow.com/faq) – 2013-03-24 10:38:54

回答

0
$("#navi").mouseover(function(){ 

    $("#navi").stop().animate({width:'200px'},{queue: false,easing:"easeOutBounce",duration:1200}); 
    while($("#navi").is(":animated")){ 
    $("#navi").off('click').off('mouseover'); 
    //you can add all the events you want to ignore 
    //if it doesn't work, use unbind instead of off 
    }; 
    //re-enable these events 
    $("#navi").on('click').on('mouseover'); //here you could use bind instead of on 
}); 
+0

我已經做了(請參閱第一篇文章的編輯),但當光標橫過字母時,動畫會出現口吃。 – John 2013-03-24 10:50:06

+0

你需要動畫多少次? – saada 2013-03-24 10:51:19

+0

它的導航面板在鼠標懸停時移出。 – John 2013-03-24 10:58:53