How can I set my first image to preload at the following link so I don't have a white space then it scrolls onto the second image.
Maybe it would look better using a fade in fade out?
here is my code
$(function() {
var N = 0;
var K = 0;
var tt
START();
function START() {
tt = setInterval(NEXT, 3000);
}
function NEXT() {
if( N < $('.photo-slider-img').length - 1 ) {
N++;
} else {
N = 0;
}
CHANGE();
}
function CHANGE() {
K = 1;
$('.photo-slider-img.NOW').stop().animate({left: '-100%'}, 500);
$('.photo-slider-img').eq(N).stop().css({left: '100%'}).animate({left: 0}, 500, OK);
}
function OK() {
K = 0;
$('.photo-page').removeClass('active').eq(N).addClass('active');
$('.photo-slider-img').removeClass('NOW').eq(N).addClass('NOW');
}
$('.photo-page').on('click', function() {
if( $(this).index() == N || K == 1 ) return;
if ( tt ) {
clearInterval( tt );
tt = 0;
N = $(this).index();
CHANGE();
START();
}
});
});
您始终可以将图像预加载到不可见的dom节点中-这会缓存图像,因此您可以立即使用它
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.