【发布时间】:2014-08-22 04:15:26
【问题描述】:
【问题讨论】:
【问题讨论】:
以下应该可以工作。
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 提供的 Carousel 文档 Sencha Touch 2.0 Carousel
【讨论】: