var slideWidth = $('#carousel #slideContainer .slide').width();
var slidePos = (($('ul#carousel_nav li').index(this)) * slideWidth);
slidePos = Math.abs(slidePos) * -1;
$('#carousel #slideContainer .slide .slideContents').stop();
$('#carousel #slideContainer').stop();
$('#carousel #slideContainer .slide .slideContents').fadeOut( 500, function()
{
$('#carousel #slideContainer').animate({ left: slidePos }, 1000, function()
{
$('#carousel #slideContainer .slide .slideContents').fadeIn( 500 );
});
});
构建一个包含动画/回调链的jQuery滚动条。单击按钮时,div '#carousel #slideContainer .slide .slideContents
应淡出,其容器div '#carousel #slideContainer .slide .slideContents
移动n像素(slidePos)
当exectued时,动画回调并不总是在上一个动画结束时触发,整个序列变得脱节了?!
答案 0 :(得分:1)
在我看来,就像皮塔说的作品一样
var slideWidth = $('#carousel #slideContainer .slide').width();
var slidePos = (($('ul#carousel_nav li').index(this)) * slideWidth);
slidePos = Math.abs(slidePos) * -1;
$('#carousel #slideContainer .slide .slideContents').stop(true);
$('#carousel #slideContainer').stop(true);
$('#carousel #slideContainer .slide .slideContents').fadeOut( 500, function()
{
$('#carousel #slideContainer').animate({ left: slidePos }, 1000, function()
{
$('#carousel #slideContainer .slide .slideContents').fadeIn( 500 );
});
});