javascript - .load() is not firing for all images -
i have created gallery script, first loads images shown http://bit.ly/9aqdr3
there 36 images image.load() firing 27 times. here code
var c = 0; for(var =1; <= 36; i++){ var img = '<img width="500" src="images/' + + '.jpg" />' $('#gallery .images').append(img); } $('#gallery .images img').css({display: 'block', position: 'absolute', left: '0px', top: '0px'}); $('#gallery .images img').hide(); totalimages = $('#gallery .images img').size(); $('#gallery .images img').load(function(){ c++; var ip = parseint((c/totalimages)*100); $('#gallery .images p').text('loading ... ' + ip + '%'); if(c == totalimages){ $('#gallery .images p').remove(); $('#gallery .images img').eq(0).show(); interval = setinterval(startanimation, 100); isplaying = true; } });
the problem seems here
if(c == totalimages){ $('#movieshow .images p').remove(); $('#movieshow .images img').eq(0).show(); interval = setinterval('startanimation()', 100); isplaying = true; }
try print on firebug console c , totalimages, maybe have problem increment of c variable or totalimages not expected value.
note: instead of
interval = setinterval('startanimation()', 100);
please use
interval = setinterval(startanimation, 100);
so can avoid scope resolution expensive eval()
Comments
Post a Comment