Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 21st, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var elem = $('div');
  2. var count = elem.length;
  3.  
  4. var state = [];
  5.  
  6. var loop = function(){
  7.  
  8.   setTimeout(function(){
  9.     elem.each(function(){
  10.       var that = this;
  11.       var $this = $(this);
  12.       var height = Math.random() > 0.9? Math.random()*30 : (state.filter(function(a){ return a[0] == that; })[0] || [0, 0])[1]*0.9;
  13.       state = state.filter(function(a){ return a[0] != that; }).concat([[that, height]]);
  14.       $this.css({
  15.         'background': '#fff',
  16.         'bottom': height + 1,
  17.         'height': height + 1
  18.       });
  19.     });
  20.     loop();
  21.   }, 30);
  22.  
  23. }
  24.    
  25. loop();