Skip to content

Instantly share code, notes, and snippets.

@lucasmazza
Created June 15, 2011 02:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lucasmazza/1026351 to your computer and use it in GitHub Desktop.
Save lucasmazza/1026351 to your computer and use it in GitHub Desktop.
Animation chain using jQuery
// `then` isn't chainable, so we use `pipe`, which also accepts a 2nd callback for failure filters
// http://api.jquery.com/deferred.pipe/
$.Deferred(function(dfr) {
dfr
.pipe(function() { $('.first').fadeIn() })
.pipe(function() { $('.second').fadeIn() })
.pipe(function() { $('.third').fadeIn() })
}).resolve()
// Then function inside the function inside the function inside the...
$(".first").fadeIn(function() {
$(".second").fadeIn(function() {
$(".third").fadeIn()
})
})
// IMHO, we should get rid of anon functions and use the jQuery effect functions as top level objects.
$.pipe($('.first').fadeIn, $('.second').fadeIn, $('.third').fadeIn);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment