Closed ajaxAnnie closed 7 years ago
html:scroller里面多个动态生成的div元素 css:
position: relative; z-index: 1; width: 7.1rem; background: #fff; overflow: hidden; }
position: absolute; z-index: 1; -webkit-tap-highlight-color: rgba(0,0,0,0); width: 6.1rem; user-select: none; background: #fff; transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); -moz-transform: translate3d(0,0,0); } (function(){ var obj=login.extend({ constructor:function login(){ this.myScroll=""; //iscroll this.otp={}; global.addEventListener("load",this.loadScroll(),false); //初始化 } })
loadScroll:function(global){ let _this=this; this.otp={ fadeScrollbars: true,//滚动时显示滚动条,默认影藏,并且是淡出淡入效果 bounce:true,//边界反弹 shrinkScrollbars:'clip',// 当滚动边界之外的滚动条是由少量的收缩。'clip' or 'scale'. onScrollMove: function () { if((this.y < this.maxScrollY+10) && (this.pointY < 11)){ this.scrollTo(0, this.maxScrollY, 400); return; } else if (this.y > 10 && (this.pointY > global.innerHeight - 11)) { this.scrollTo(0, 0, 400); return; } }
};
this.myScroll = new iScroll('wrapper', _this.otp);
},
setWrapperHeight:function(){ //设置记录多账户容器的高度 let wrapperHeight = document.getElementById('wrapper'); let scroller = document.getElementById('scroller'); if(scroller.children.length <=4 ){ //当用户名列表小于4条时没有滚动条,但依然可以上下拉动 let s=scroller.offsetHeight; wrapperHeight.style.height=scroller.offsetHeight-1+'px'; }else{ wrapperHeight.style.height=220+'px'; this.myScroll.destroy(); this.otp.scrollbars=true; //当用户名列表超过4条,出现滚动条 this.myScroll = new iScroll('wrapper', this.otp); } scroller.style.minHeight=parseFloat(wrapperHeight.style.height)+1+'px'; }, }(window))
呃。。。你用的是哪个版本。?建议升级到最新版
留下你的代码 show your code