且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

脚本不是局部回传后正常工作

更新时间:2023-12-05 15:09:58

Blazemonger 给关于你的问题的解决方案

Blazemonger has given a solution regarding your problem

要优化整个事情多一点,可以消除currentPosition变量和moveSlide子功能,并且只使用一个回调的 .animate方法

To optimize the whole thing a little more, you can eliminate the currentPosition variable and the moveSlide sub-function, and just use a callback in the .animate method:

function changePosition() {
    $('#slidesHolder').animate({
        'marginLeft': 0-slideWidth
    }, function() {
        $('#slidesHolder').css('marginLeft', 0)
            .children().first().appendTo('#slidesHolder');
    });
}

来源