作者mosluce ()
看板Web_Design
標題Re: [問題] jquery動畫中斷怎麼做?
時間Mon Apr 20 22:25:27 2009
試試看
.hover(
function(){
$(this).css('width',100%);
$(this).animate({width:'150%'},3000);
},
function(){
$(this).css('width',150%);
$(this).animate({width:'100%'},3000);
}
);
※ 引述《evenwu (EvenWu)》之銘言:
: 之前用jquery作了一些動畫的menu還不錯
: 但一直有個困擾...
: 假設hover的時候
: .animate({width:'150%'},3000)
: 然後滑鼠離開時
: .animate({width:'100%'},3000)
: 這樣一來如果有個user很想玩,用滑鼠在那邊抖來抖去
: 動畫仍然是慢慢來,一定要跑完所有的動畫
: 我要怎麼中斷動畫?
: 比如說hover時,width還沒到150%,滑鼠就先離開
: 那就立刻停止width長到150%,往100%去縮小
: 這類的...該怎麼寫??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.104.117.109
※ 編輯: mosluce 來自: 59.104.117.109 (04/20 22:25)
→ fillano:不對吧?用$(this).stop(true,true);吧? 04/21 00:49
→ fillano:清掉queue好像不太好?用$(this).stop(false,true);好了。 04/21 00:51
推 evenwu:謝謝樓上與原po,我測測 04/21 01:46
→ mosluce:感謝F大說明(筆記 04/21 08:59