我在这里有两个问题:
1)当鼠标悬停在下面的jquery时,我尝试旋转相册中的照片,但是当鼠标悬停时循环无法停止。
2) 我不知道如何使用淡入/淡出功能进行旋转/幻灯片放映?
var photo_timers = new Array;
var photo = new Array;
var base_url = 'http://www.example.com';
function changeThumb( id, url )
{
document.getElementById(id).src = url;
}
$("img[id*='album_slideshow_']").live('mouseover', function() {
var image_id = $(this).attr("id");
var id_split = image_id.split('_');
var album_id = id_split[2];
$.post(base_url + '/ajax_rotate_album_photos.php', { album_id: album_id },
function(response) {
if(response.count > 0) {
for(var i=0; i < response.pid.length; i++) {
var photo_src = base_url + '/images/picturethumbs/' + response.pid[i].id + '-1.jpg';
photo[i] = new Image();
photo[i].src = photo_src;
}
for(var i=0; i < response.pid.length; i++) {
var photo_src = base_url + '/images/picturethumbs/' + response.pid[i].id + '-1.jpg';
photo_timers[i] = setTimeout("changeThumb('" + image_id + "','" + photo_src + "')", i*100*10);
}
}
}, "json");
}).live('mouseout', function() {
var image_id = $(this).attr("id");
var id_split = image_id.split('_');
var album_id = id_split[2];
$.post(base_url + '/ajax_rotate_album_photos.php', { album_id: album_id },
function(response) {
if(response.count > 0) {
for(var i=0; i < response.pid.length; i++) {
if( typeof photo_timers[i] == "number" ) {
clearTimeout(photo_timers[i]);
}
}
}
}, "json");
$(this).attr('src', base_url + '/images/albums/' + album_id + '.jpg');
});