SyntaxStudy
Sign Up
jQuery Intermediate 4 min read

Deferred in Animations

Animation Promises

jQuery animations return a Promise via .promise() that resolves when all animations on the element complete — useful for chaining animations.

Example
$("#logo")
  .fadeIn(500).promise()
  .then(function() {
    return $("#tagline").slideDown(400).promise();
  })
  .then(function() {
    return $("#cta").fadeIn(300).promise();
  })
  .done(function() {
    console.log("Intro animation complete");
  });
Pro Tip

Animation .promise() resolves when the animation queue is empty — works with any queued animation.