[英]using iscroll with jquery mobile
我正在努力讓我的頭發試圖讓iscroll 4與jQuery Mobile一起工作。
一切正常,我禁用JQM ajax默認導航,但我想保留這個。
我的問題是我無法解決如何成功調用/綁定iscroll所以它適用於需要它們的頁面。 我試過pageinit()和pagecreate()無濟於事。
任何指針都非常贊賞。
一個。
我在pageshow
和orientationchange
事件上初始化/刷新iScroll實例。 我在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.