Skip to content

Instantly share code, notes, and snippets.

@hemantajax
Created May 28, 2012 06:03
Show Gist options
  • Save hemantajax/2817596 to your computer and use it in GitHub Desktop.
Save hemantajax/2817596 to your computer and use it in GitHub Desktop.
promise with animation
<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<style>
#wrapper div{
float:left;
width:200px;
height:200px;
line-height:200px;
margin:10px;
background-color: #0f0;
text-align:center;
}
</style>
</head>
<body>
<div id="wrapper">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
(function(){
$.each($("#wrapper").find("div"),function(i,obj){
$(this).fadeOut(2000 * ++i);
console.log(i);
}).promise().done(function(){
console.log("All Done");
});
console.log("Outer Done..");
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment