2012-02-14 91 views

回答

1

afaik,iScroll没有提供这样的功能。 你可以尝试煎茶触摸,它有各种UI组件, 的,这是煎茶触摸2.0 Sencha Touch 2.0 Carousel

+2

我提高了这个。这不是iScroll应该如何使用的目的。在jQuery Mobile和其他框架中还有其他几个Carousel插件。 – zvona 2012-02-14 08:10:07

4

下应努力提供旋转木马的文档。

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); 
}); 

希望可以帮助任何人无意中发现这个网页!

+1

不错的诺亚! – 2013-02-06 06:06:14