gpt4 book ai didi

javascript - jquery 上的动画损坏

转载 作者:行者123 更新时间:2023-11-28 09:02:23 24 4
gpt4 key购买 nike

请帮我改正我的脚本:http://jsfiddle.net/b36cM/

                if(direction == -1){
wrapperElements.children(':last').after($('#carousel > ul').children().slice(0, options.rotateBy).clone());

shiftAction();

wrapperElements.children().slice(0, options.rotateBy).remove();
}
else{
// wrapperElements.children(':first').after($('#carousel > ul').children().slice(carouselLength - options.rotateBy, carouselLength).clone());

// shiftAction();

// wrapperElements.children().slice(carouselLength - options.rotateBy, carouselLength).remove();
}
}

function shiftAction(){
console.log(offset);

wrapperElements.animate({
'left': offset
}, options.speed, function(){
running = false;
});
}
}

当单击#prev时,动画会将两个元素向左移动。我只想平滑地滚动一项。

最佳答案

请注意,shiftAction() 和remove() 异步运行,因此当元素被删除时动画尚未完成,这会使您的动画跳转到第一个元素,您可以使用它进行检查

setTimeout(function() {
wrapperElements.children().slice(0, options.rotateBy).remove();
},5000);

但它不能解决动画的洞问题

关于javascript - jquery 上的动画损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17548297/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com