我已经实现了从1000多个图像中获取单个图像的代码。但是Ajax调用改变了图像,导致每个映像的下载时间不同。该如何使图像相互平滑转换?即没有任何闪烁和Ajax处理图像。
You could pre-select the images you are about to load and store it in a persistent array:
var image_paths = new Array();
/* fill image_paths */
window.preload_images = new Array();
for (var i in image_paths) {
var image_src = image_paths[i];
var img = new Image();
img.src = image_src;
preload_images.push(img);
}
This will tell the DOM to load the image into a JavaScript Image
object but to not destroy it unless preload_images
is unset.