一些配置项:能够从源码里关键词搜索测试
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);