我遇到了普通(非ajax)函数的问题,这些函数在每个函数中都涉及很多动画.目前我只有一个setTimeout功能之间,但这并不完美,因为没有浏览器/计算机是相同的.
附加说明:它们都有单独的动画/等碰撞.
我不能简单地把一个放在另一个的回调函数中
// multiple dom animations / etc
FunctionOne();
// What I -was- doing to wait till running the next function filled
// with animations, etc
setTimeout(function () {
FunctionTwo(); // other dom animations (some triggering on previous ones)
}, 1000);
Run Code Online (Sandbox Code Playgroud)
无论如何在js/jQuery中有:
// Pseudo-code
-do FunctionOne()
-when finished :: run -> FunctionTwo()
Run Code Online (Sandbox Code Playgroud)
我知道$.when()&$.done(),但那些是针对AJAX的......
jQuery有一个名为$ .timers的暴露变量(由于某种原因未在jQuery文档中列出),它包含当前正在进行的动画数组.
function animationsTest (callback) {
// Test if ANY/ALL page animations are currently active …Run Code Online (Sandbox Code Playgroud)