Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div class="block" data-reps="77777">
    This is slow
  </div>
  
  <hr />
  
  <div class="block" data-reps="100">
    This is fast
  </div>
  <hr />
  <img src="http://static.jsbin.com/images/jsbin_static.png" class="image"/>
</body>
</html>
 
.block {
  height: 155px;
  width: 250px;
  background: #cccccc;
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  color: #ffffff;
  font-size: 28px;
  cursor: pointer;
}
.image {
  height: 400px;
  width: 400px;
}
.block.working {
  background-image: url( http://static.jsbin.com/images/jsbin_animated.gif);
}
 
// noprotect
$(".block").click(function(){
  var $block = $(this);
  $block.addClass('working');
  
  var reps = $block.attr("data-reps");
    
    // Make the processor work out
  for (var i = reps - 1; i >= 0; i--) {
    
    $(".image").css({height:i / reps * 400});
    $(".image").css({width:i / reps * 400});
  }
    $(".image").css({height:400});
    $(".image").css({width:400});
    
$block.text( "Process complete");
 
// Doesn't show until we reach here
  $(this).removeClass('working');
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers