Skip to content

Instantly share code, notes, and snippets.

@matharchod
Created October 19, 2011 19:40
Show Gist options
  • Save matharchod/1299430 to your computer and use it in GitHub Desktop.
Save matharchod/1299430 to your computer and use it in GitHub Desktop.
A jQuery toggle function that uses callbacks to animate elements in a particular order.
/* SET #PORTFOLIO TOGGLE */
$("#portfolio_toggle").toggle(
function(){
portfolioOpen();
},
function(){
portfolioClose();
}
);
function portfolioOpen(){
$('#portfolio').load('PUTYOURSAMEDOMAINLINKHERE', function(){
busy();//BUSY MESSAGE
$('#portfolio').slideDown('slow', function(){
$('#portfolio ul').fadeIn('fast',function(){
$('#wrapper').animate({width:'900px'});//RESIZE WRAPPER
});
$('#portfolio ul li').each(function (i){
var me = $(this);
setTimeout(function(){ $(me).fadeIn('slow'); }, (20 * i));//FADE IN ANIMATION
});
});
});
}
function portfolioClose(){
$('#wrapper').animate({width: '75%'});//RESIZE WRAPPER
$('#portfolio ul li').fadeOut('fast',function(){
$('#portfolio').slideUp('slow', function(){
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment