Skip to content

Instantly share code, notes, and snippets.

@FiNGAHOLiC
Forked from lucasmazza/deffered.js
Created March 14, 2012 07:28
Show Gist options
  • Save FiNGAHOLiC/2034844 to your computer and use it in GitHub Desktop.
Save FiNGAHOLiC/2034844 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