How to run one JavaScript animation after another?

I created 2 JavaScript animation functions, and they run simultaniously. How can i make the second function run after the first one? https://code.sololearn.com/Wv7XGJ9f14jL/?ref=app

5/15/2019 4:45:18 PM


4 Answers

New Answer


You can call the second function after the first one finished like this: if (pos1 >= 200) { clearInterval(t1); t2 = setInterval(move2, 3); }


Airree It worked, thank you very much 😊


You can use promises as well uncomment lines 182-193 and comment line 180 https://code.sololearn.com/WM0pzE0DictQ/?ref=app


animation query in jquery can help