Loading Elements for Images


/ Published in: JavaScript
Save to your folder(s)

needs to be modified to be more general purpose.


Copy this code and paste it in your HTML
  1. var CoverUps = {
  2. initialized: false,
  3. todo: [],
  4. initialize: function(thumbnails){
  5. thumbnails.each(function(i){
  6. var image = new Image();
  7. image.onload = function(){
  8. coverup = $('project' + i.id + '_cover-up');
  9. if(coverup){
  10. new Effect.Fade(coverup);
  11. }else{
  12. CoverUps.todo.push('project' + i.id + '_cover-up');
  13. }
  14. }
  15. image.src = i.image;
  16. });
  17. Event.observe(document, 'dom:loaded', CoverUps.fadeLeftovers);
  18. },
  19. fadeLeftovers: function(){
  20. CoverUps.todo.each(function(e){
  21. new Effect.Fade(e);
  22. });
  23. }
  24. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.