无限垂直滚动div元素 [英] Infinite vertical scroll div element
本文介绍了无限垂直滚动div元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有垂直滚动条的示例
[样本]: http://jsfiddle.net/e5dtyLjw/
我想像无限一样做这个样本,在滚动结束时在样本上,它会移到顶部 我不想要它,就像无限一样
I want to do this sample like infinite, on the sample when scroll is end, its going to top I dont want it, i want to it like infinite
这是我的代码:
var itemCount = 10, activeScroll = 0, countScroll = 0;
setInterval(function() {
if(countScroll == (itemCount - 6)) {
activeScroll = 0;
countScroll = 0;
$('#list').animate({scrollTop: 0});
}
else {
activeScroll += 40;
countScroll += 1;
$('#list').animate({scrollTop: activeScroll});
}
}, 1000);
更新:我确实尝试过一些新的东西,但是我希望那样做.没有效果:/
update: I did try something new, I want it just like that but this way. There is no effect :/
http://jsfiddle.net/e5dtyLjw/2/
推荐答案
如果我理解正确,这就是您想要的
if I understand you right, this is what you're looking for
setInterval(function(){
$('#list').stop().animate({scrollTop:40},400,'swing',function(){
$(this).scrollTop(0).find('span:last').after($('span:first', this));
});
}, 1000);
如果要获得幻灯片效果,必须使用.animate()
You have to use .animate() if you want that slide effect
这篇关于无限垂直滚动div元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文