我已经使用SplitView - http://asyraf9.github.com/jquery-mobile/ - (并且似乎使用ScrollView组件)和jQuery Mobile一起实现了WebApp。一切工作正常...使用SplitView获取面板的滚动位置(jQuery Mobile)
在面板中我有一个元素的列表,当滚动到达列表的末尾时应该动态添加元素。在iPhone上,我不使用SplitView,而是使用iScroll - http://cubiq.org/iscroll - 以及下面的代码来实现这一点(它正在工作)。
HTML:
<div data-role="panel" data-id="menu" data-hash="crumbs" style="z-index: 10000;" id="Panel">
<div data-role="page" id="Root" class="Login" onscroll="console.log('onscroll');">
<div data-role="content" data-theme="d" onscroll="console.log('onscroll');">
<div class="sub">
<ul data-role="listview" data-theme="d" data-dividertheme="a" class="picListview" id="PortfolioList">
<!-- Content added dynamically -->
</ul>
</div>
</div>
</div>
</div>
的Javascript:
var defaultIScrollOptions = {
useTransition: true,
onScrollStart: function() {
this.refresh();
},
onScrollEnd: function() {
if (this.elem && this.id) {
possiblyDisplayNextDocuments(this.y, this.elem, this.id);
}
}
};
iScrolls.push(new iScroll(document.getElementById("searchResults").parentNode, defaultIScrollOptions));
但在使用时SPLITVIEW我真的不知道要监听绑定或如何获得滚动位置,其事件和元素。我已经尝试过几种组合,但没有取得好成绩。最好的是以下几点:
$("#PortfolioList").scrollstop(function(event) {
console.log("scrollstop: "+$("#PortfolioList").scrollTop());
});
我的问题是:我在用正确的事件监听器(因为它已经触发althgough滚动动画仍然在使用),我如何获得滚动位置?
感谢您的快速回答。 iScroll的问题在于性能。列表可能会变得很长,然后iScroll在touchstart上保持缓慢。或者有什么我可以做的iScroll的性能问题? – Chagemei 2012-02-17 15:00:20