JSFiddle - React, Tailwind, and code Playground
by Torwan
HTML
<a href="http://stackoverflow.com/questions/12116505/wait-till-a-function-with-animations-is-finished-until-running-another-function">link</a>
JavaScript
var FunctionOne = function () {
var
a = $.Deferred(),
b = $.Deferred();
// some fake asyc task
setTimeout(function () {
console.log('a done');
a.resolve();
}, Math.random() * 4000);
// some other fake asyc task
setTimeout(function () {
console.log('b done');
b.resolve();
}, Math.random() * 4000);
return $.Deferred(function (def) {
$.when(a, b).done(function () {
def.resolve();
});
});
};
var FunctionTwo = function () {
console.log('FunctionTwo');
};
FunctionOne().done(FunctionTwo);