第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

等待帶有動畫的功能完成,直到運行另一個功能

等待帶有動畫的功能完成,直到運行另一個功能

猛跑小豬 2019-11-25 14:34:48
我在正常(非ajax)函數中遇到了問題,每個函數中都包含很多動畫。目前,我只是具有一個setTimeoutbetween函數,但這并不是完美的,因為沒有瀏覽器/計算機是相同的。附加說明:它們都有碰撞的單獨動畫/等。我不能簡單地將一個放在另一個的回調函數中// multiple dom animations / etcFunctionOne();// What I -was- doing to wait till running the next function filled// with animations, etcsetTimeout(function () {     FunctionTwo(); // other dom animations (some triggering on previous ones)}, 1000); 無論如何在js / jQuery中有:// Pseudo-code-do FunctionOne()-when finished :: run -> FunctionTwo()我知道$.when()&$.done(),但是這些是針對AJAX的...我更新的解決方案jQuery有一個名為$ .timers的暴露變量(由于某種原因未在jQuery文檔中的任何地方列出),該變量保存當前發(fā)生的動畫數組。function animationsTest (callback) {    // Test if ANY/ALL page animations are currently active    var testAnimationInterval = setInterval(function () {        if (! $.timers.length) { // any page animations finished            clearInterval(testAnimationInterval);            callback();        }    }, 25);};基本用法:// run some function with animations etc    functionWithAnimations();animationsTest(function () { // <-- this will run once all the above animations are finished    // your callback (things to do after all animations are done)    runNextAnimations();});
查看完整描述

3 回答

?
HUH函數

TA貢獻1836條經驗 獲得超4個贊

在第一個函數的末尾添加以下內容


return $.Deferred().resolve();

像這樣調用兩個函數


functionOne().done(functionTwo);


查看完整回答
反對 回復 2019-11-25
?
Helenr

TA貢獻1780條經驗 獲得超4個贊

除了Yoshi的答案,我還找到了另一個非常簡單的動畫(回調類型)解決方案。


jQuery有一個公開變量(由于某種原因未在jQuery文檔中列出),稱為$ .timers,該變量保存當前正在發(fā)生的動畫數組。


function animationsTest (callback) {

    // Test if ANY/ALL page animations are currently active


    var testAnimationInterval = setInterval(function () {

        if (! $.timers.length) { // any page animations finished

            clearInterval(testAnimationInterval);

            callback();

        }

    }, 25);

};

基本用法:


functionOne(); // one with animations


animationsTest(functionTwo);

希望這可以幫助一些人!


查看完整回答
反對 回復 2019-11-25
  • 3 回答
  • 0 關注
  • 688 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號