Re: [問題] jquery動畫中斷怎麼做?

看板Web_Design作者時間16年前 (2009/04/20 22:25), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
試試看 .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)

04/21 00:49, , 1F
不對吧?用$(this).stop(true,true);吧?
04/21 00:49, 1F

04/21 00:51, , 2F
清掉queue好像不太好?用$(this).stop(false,true);好了。
04/21 00:51, 2F

04/21 01:46, , 3F
謝謝樓上與原po,我測測
04/21 01:46, 3F

04/21 08:59, , 4F
感謝F大說明(筆記
04/21 08:59, 4F
文章代碼(AID): #19x8NO4T (Web_Design)