[英]using iscroll with jquery mobile
Im currently pulling my hair out trying to get iscroll 4 working with jQuery Mobile. 我正在努力让我的头发试图让iscroll 4与jQuery Mobile一起工作。
It all works fine it i disable JQM ajax default navigation but I would like to retain this. 一切正常,我禁用JQM ajax默认导航,但我想保留这个。
My issue is I cant work out how to successfully call/bind iscroll so it works with the pages that need them. 我的问题是我无法解决如何成功调用/绑定iscroll所以它适用于需要它们的页面。 I have tried pageinit() and pagecreate() to no avail.
我试过pageinit()和pagecreate()无济于事。
Any pointers much appreciated. 任何指针都非常赞赏。
A. 一个。
I initialize/refresh the iScroll instances on the pageshow
and orientationchange
events. 我在
pageshow
和orientationchange
事件上初始化/刷新iScroll实例。 I set a class on data-role="content"
divs that I want to be scrollable (in this instance I used the .content
class). 我在
data-role="content"
div上设置了一个我想要滚动的div(在这个例子中我使用了.content
类)。
var myScroll = [];
$(document).delegate('[data-role="page"]', 'pageshow', function () {
if ($.mobile.activePage.find('.content').length > 0) {
if (this.id in myScroll) {
myScroll[this.id].refresh();
} else {
myScroll[this.id] = new iScroll($.mobile.activePage.find('.content')[0].id, {
hScroll : false,
vScroll : true,
hScrollbar : false,
vScrollbar : true,
fixedScrollbar : true,
fadeScrollbar : false,
hideScrollbar : false,
bounce : true,
momentum : true,
lockDirection : true
});
}
}
});
$(window).bind('orientationchange', function () {
if ($.mobile.activePage[0].id in myScroll) {
myScroll[$.mobile.activePage[0].id].refresh();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.