[問題] 使用jQuery queue的疑問

看板Ajax作者 (CryFather)時間10年前 (2015/09/08 20:00), 10年前編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
各位好, 這兩天在做一個串聯動畫的特效的時候遇到問題: 以下是我各種google之後目前嘗試出來的,很遺憾不是我想要的效果... var theQueue = $({}); theQueue.queue('xxx', function (next){ $("#element1").css('-webkit-transition','-webkit-transform 3s') next(); }); theQueue.queue('xxx', function (next){ $("#element3").show('slide',{direction:"up"}, 5000); $("#element4").show('slide',{direction:"down"}, 5000); next(); }); theQueue.queue('xxx', function (next){ $("#element3").hide('slide',{direction:"right"}, 5000); $("#element4").hide('slide',{direction:"left"}, 5000); next(); }); theQueue.dequeue('xxx'); 簡而言之,有好多個元素我想要讓他們依照順序進行動畫 所以我想把這些function加進共同的 theQueue.queue('xxx'..... 但是目前run起來結果只有 跟同一個元素相關的動畫有照順序 不同元素的效果仍然同時被call出來 變成畫面一團亂... 請問大大我對Queue的操作方法哪邊理解錯了? 感謝 ----------------------------------------- 最後發現 Queue只能用在對同一個element身上... 捨棄了Queue 改用Deferred object完成 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.230.160.146 ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1441713603.A.168.html ※ 編輯: donvito (36.230.160.146), 09/08/2015 20:03:41 ※ 編輯: donvito (118.167.98.252), 09/09/2015 16:39:14

09/19 00:04, , 1F
做完動畫在執行dequeue
09/19 00:04, 1F

09/19 00:05, , 2F
queue只是不用讓你function內在包function
09/19 00:05, 2F
文章代碼(AID): #1Lxit35e (Ajax)
文章代碼(AID): #1Lxit35e (Ajax)