Posted By

mifly on 03/13/08


Tagged

javascript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

joomla


fade in


 / Published in: JavaScript
 

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

Report this snippet  

You need to login to post a comment.