我有一个大数据的div。我已经使用overflow
属性隐藏额外的数据,现在我希望我的滚动条自动移动到从第1行的第4、5、6元素和第2行的第4、5、6元素可见的位置。然后几秒钟后,我希望滚动条向左移动,这样第1行的第7、8、9和第2行的第7、8、9元素将是可见的。
如何才能做到。是否有/jQuery来解决我的问题。
这是我的JsFiddle
发布于 2013-06-03 05:09:21
请参阅jsFiddle上的示例
您只需设置.gallery
scrollLeft
var autoscrollTimer;
function cancelscrolling()
{
clearTimeout(autoscrollTimer);
}
function autoscroll()
{
var gal = $(".gallery");
// don't cancel if it is the code scrolling
gal.off("scroll");
gal.animate({ scrollLeft: "+=" + gal.width() },
function() {
setTimeout(function(){
// when the animation ends re-add the code
// to stop scrolling if the user scrolls
gal.on("scroll", cancelscrolling);
}, 1);
});
// if still not in the end, continue scrolling
if (gal.get(0).scrollWidth > (gal.get(0).scrollLeft + gal.width()))
autoscrollTimer = setTimeout(autoscroll, 3000);
}
$(".gallery").on("scroll", cancelscrolling);
// starts the loop
autoscroll();
重新开始查看另一个版本
发布于 2013-06-03 05:03:18
我认为'scroll="auto"
‘应该能做到这一点。
但你需要把它放在弹出框的身体标签里。
发布于 2013-06-03 05:36:39
嗨,你可以这样做代码
$(document).ready(function(){
lastElementLeft = $('.demo').position().left ;
scrollAmount = lastElementLeft + 200 ;
//alert(scrollAmount);
$('.demo').animate({scrollLeft: scrollAmount},1000);
});
演示程序在这里,http://jsfiddle.net/uaewc/307/
https://stackoverflow.com/questions/16890204
复制相似问题