+ 43

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

15th May 2019, 4:45 PM
Hicham BOURHIL
Hicham BOURHIL - avatar
4 Answers
+ 12
You can call the second function after the first one finished like this: if (pos1 >= 200) { clearInterval(t1); t2 = setInterval(move2, 3); }
15th May 2019, 6:15 PM
Airree
Airree - avatar
+ 37
Airree It worked, thank you very much 😊
15th May 2019, 7:56 PM
Hicham BOURHIL
Hicham BOURHIL - avatar
+ 10
You can use promises as well uncomment lines 182-193 and comment line 180 https://code.sololearn.com/WM0pzE0DictQ/?ref=app
17th May 2019, 9:36 AM
Burey
Burey - avatar
0
animation query in jquery can help
17th May 2019, 1:29 PM
moxeed
moxeed - avatar