我想为 7 个动画预加载 152 个 jpg 图像。我正在尝试在预加载该动画所需的图像(例如前 40 个图像)后立即运行单个动画。在所有浏览器中,它以及在 android 中都可以正常工作。但是在ipad,动画(背景图像更改)运行不顺畅,直到所有 152 个图像都不会预加载。
function preload(arguments,index) {
console.log(index)
for(var i=1;i<=eval(imagesPerScreen[index][1]-imagesPerScreen[index][0]+1);i++){
scheen[index][i-1] = new Image();
scheen[index][i-1].src = arguments[index][eval(i-1)];
$(scheen[index][i-1]).load(function(){
imgLoaded++;
var percent=parseInt((imgLoaded/(imagesPerScreen[index][1]-imagesPerScreen[index][0]+1)*100).toFixed())+8;
if(!isiPad){
//document.getElementById("loadingStatus").innerHTML="loading.. "+percent+"%";
$("#loadingStatus").css('width',percent+'px');
}
else{
//$("#loadingStatus").css('display','none');
$("#loadingStatus").css('width',percent+'px');
}
});
}
scheen[index][eval(imagesPerScreen[index][1]-imagesPerScreen[index][0])].onload= function() {
++screenLoaded;
imgLoaded=0;
$("#rightbutton").css('display','block');
$("#rightArea").css('display','block');
$("#loadingStatus").css('display','none');
$("#status").fadeOut("fast");
$("#preloader").fadeOut("fast");
if(waiting){moveNext();}
if(screenLoaded<7){
preload(pics,index+1)
}
}; }