Posted By

pdswan on 05/19/09


Tagged

prototype loading indicator


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


Loading Elements for Images


 / Published in: JavaScript
 

needs to be modified to be more general purpose.

  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
Posted By: pdswan on May 19, 2009

sample initialization: CoverUps.initialize([{id: 41, image: '/uploads/images/descriptions/thumbnails/featured/fea-thumb-21240849366.jpg'}, {id: 40, image: '/uploads/images/descriptions/thumbnails/featured/fea-thumb-11240848400.jpg'}, {id: 15, image: '/uploads/images/descriptions/thumbnails/featured/fea-thumb-21240846805.jpg'}]);

You need to login to post a comment.