Posted By

mifly on 03/13/08


Tagged

javascript


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

joomla
Jman


slide down


 / Published in: JavaScript
 

  1. function slideDown( elem ) {
  2. // Find the full, potential, height of the element
  3. var h = fullHeight( elem );
  4.  
  5. // Start the slide down at 0
  6. elem.style.height = '0px';
  7.  
  8. // Show the element (but you can see it, since the height is 0)
  9. show( elem );
  10.  
  11. // We�re going to do a 20 �frame� animation that takes
  12. // place over one second
  13. for ( var i = 0; i <= 100; i += 5 ) {
  14. // A closure to make sure that we have the right �i�
  15. (function(){
  16. var pos = i;
  17.  
  18. // Set the timeout to occur at the specified time in the future
  19. setTimeout(function(){
  20.  
  21. // Set the new height of the element
  22. elem.style.height = ( pos / 100 ) * h + "px";
  23.  
  24. }, ( pos + 1 ) * 10 );
  25. })();
  26. }
  27. }

Report this snippet  

You need to login to post a comment.