Iscroll5的簡單配置和方法

一些配置項:能夠從源碼裏關鍵詞搜索測試

this.options = {
    eventPassthrough:true,//本身試
    scrollX:true,//橫向能夠滾
    scrollY:false,//縱向不能夠滾
    snap: true,//對齊
    snapSpeed: 400,//對齊速度
    directionLockThreshold: 5,//多少像素開始監聽
    momentum: true,//是否有慣性
    preventDefault: true//阻止默認事件
};

一些方法:能夠從源碼裏關鍵詞搜索
refresh()//刷新
scrollTo()//滾到
next()//下一個index
prev()//上一個indexthis

解決當頁面沒有加載完高度計算不正確的狀況
第一種測試效果仍是不太好
var scrollerHeight = myScroll.scrollerHeight;
var timer=window.setInterval(function(){
    if(scrollerHeight==myScroll.scrollerHeight){
        window.clearInterval(timer);
    }
    $("#main_scroll").height($("#main_scroll")[0].clientHeight+"px");
    myScroll.refresh();
},200);
第二種
var timer=window.setInterval(function(){
    var scrollerHeight = $("#main_scroll")[0].clientHeight;
        if(scrollerHeight==myScroll.scrollerHeight){
            window.clearInterval(timer);
        }
    myScroll.refresh();
    },500);
相關文章
相關標籤/搜索