www.webdeveloper.com
Results 1 to 1 of 1

Thread: Sequentially loading images erratic

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    124

    Sequentially loading images erratic

    Hi all

    jsfiddle here - http://jsfiddle.net/bM2Rp/

    Demo here - http://www.ttmt.org.uk/load/

    I'm trying to sequentially load images using imagesLoaded.js to check when the image is loaded before loading the next.

    My problem is the first time the page load there is a long delay before the first image loads and then the remaining images can load erratically.

    Loading the page again the images load as expected.

    I realise the images have to download but they're not big.

    Is there something wrong with my code that is causing this.


    Code:
    $(function() {
    
        	var i=0;
    
          var checkLoad = function(){
        		lis = $(' li img');
        		img = lis.eq(i);
        		img.imagesLoaded(function(){
        			img.fadeIn(200);
    
        			if(i<lis.length){
        				i++;
        				var timer = setTimeout(function(){
        						checkLoad();
        				}, 100)
        			}	
            });
          }
    
        	checkLoad();
    
        });
    Last edited by ttmt; 06-06-2013 at 10:15 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles