有谁知道如何让iScroll像旋转木马一样,有没有办法让iScroll在“ul”中自动循环?
因为我想在iOS上使用它,所以我一直在试图弄清楚..
非常感谢您的宝贵时间。
以下应该工作。
setInterval(function () {
myScroll.scrollToPage('next', 0, 400);
}, 2000);
您当然必须检查何时到达轮播结束 (curPageX)。
======
更新:在 iScroll 5 中,代码略有变化,你需要做这样的事情来启动自动循环;同时可选地在用户交互(触摸/滑动)后停止自动滚动。
/* start auto-scrolling */
myInterval = setInterval(autoScroll, 5000);
/* function handles the looping of the carousel */
function autoScroll() {
var currPage = myScroll.currentPage.pageX + 1;
if(currPage == myScroll.pages.length) {
myScroll.goToPage(0, 0, 250);
} else {
myScroll.goToPage(currPage, 0, 250);
}
}
/* stops auto-scrolling on swipe (using jQuery .on() method) */
myScroll.on('beforeScrollStart', function() {
clearInterval(myInterval);
});
希望对偶然发现此页面的任何人有所帮助!
afaik,iScroll 没有提供这样的功能。你可以试试 Sencha Touch,它有各种 UI 组件,这是 Sencha Touch 2.0 Sencha Touch 2.0 Carousel提供的 Carousel 文档