Skip to content

Instantly share code, notes, and snippets.

@paulnett
Forked from cowboy/jquery.ba-seq.js
Created May 7, 2012 23:26
Show Gist options
  • Select an option

  • Save paulnett/2631398 to your computer and use it in GitHub Desktop.

Select an option

Save paulnett/2631398 to your computer and use it in GitHub Desktop.

Revisions

  1. @cowboy cowboy created this gist Mar 2, 2011.
    26 changes: 26 additions & 0 deletions jquery.ba-seq.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    /*!
    * jQuery seq - v0.1 - 03/1/2011
    * http://benalman.com/
    *
    * Copyright (c) 2011 "Cowboy" Ben Alman
    * Dual licensed under the MIT and GPL licenses.
    * http://benalman.com/about/license/
    */

    (function($){

    $.fn.seq = function( fn, done ) {
    var elems = this;

    if ( elems.length ) {
    fn.call( elems[0], function() {
    $.fn.seq.call( elems.slice(1), fn, done );
    });
    } else if ( done ) {
    done();
    }

    return elems;
    };

    })(jQuery);
    17 changes: 17 additions & 0 deletions usage.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    elems.hide().seq(function(next){
    $(this).fadeIn( 100, next );
    });

    elems.hide().seq(function(next){
    $(this).fadeIn( 100, next );
    }, function(){
    console.log( "done!" );
    });

    (function loopy(elems){
    elems.hide().seq(function(next){
    $(this).fadeIn( 100, next );
    }, function(){
    loopy( elems.slice(1) );
    });
    })( $("li") );