在对您提供的代码进行一些整理之后(并将其移至 jsfiddle),这就是(我认为)您想要的东西。
jscroller 的功能相对有限,所以我必须进行一些调整才能将其组合在一起:
function SectionManager(){
this.currentSection = null;
this.sections = $("#content .section");
this.numSections = this.sections.length;
this.transition = function (current){
//SCROLLER CODE STARTS HERE....
$jScroller.config.refresh = 100;
// Add Scroller Object
$jScroller.config.obj = [];
$jScroller.add(
"#content .section.active .activityTbl",
"#content .section.active .activityTbl > table",
"up",
3
);
// Start Autoscroller
$jScroller.start();
$jScroller.cache.init = true;
//SCROLLER CODE ENDS HERE....
};
this.callback = function (){
this.currentSection = (this.currentSection != null)
? (this.currentSection + 1) % this.numSections
: 0
;
$("#content .section").removeClass("active");
$("#content .section:eq(" + this.currentSection + ")").addClass("active");
this.transition();
}
this.run = function(){
this.callback();
};
}
manager = new SectionManager();
manager.run();
同样值得注意的是,我必须覆盖 $jScroller.scroll 函数以包含一个异步回调,以便在到达终点时触发:这将触发管理器的回调函数并将滚动功能转移到下一部分。
编辑:有关详细信息,请参阅jsfiddle