Skip to content

Commit

Permalink
feat: Maintain linear flow of execution by using async and await
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-a-s committed Jul 6, 2024
1 parent eda744b commit 4ebcc0b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const alice1 = document.querySelector("#alice1");
const alice2 = document.querySelector("#alice2");
const alice3 = document.querySelector("#alice3");

alice1.animate(aliceTumbling, aliceTiming).finished
.then(() => alice2.animate(aliceTumbling, aliceTiming).finished)
.then(() => alice3.animate(aliceTumbling, aliceTiming));
async function animateAlice() {
await alice1.animate(aliceTumbling, aliceTiming).finished;
await alice2.animate(aliceTumbling, aliceTiming).finished;
await alice3.animate(aliceTumbling, aliceTiming);
}

animateAlice();

0 comments on commit 4ebcc0b

Please sign in to comment.