因为现在做的项目在手机上的,而使用 overflow:
test 服务条款撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人撒旦哈萨克的哈萨克觉得哈萨克觉得很我们是好人好人
返回确定
js:
function TouchScroll(obj){ this.frd = document.getElementById(obj.frd), this.ID = document.getElementById(obj.ID), this.timer = obj.timer, this.lastY = 0, this.startY = 0, this.height = 0, this.sTop = 0, this.scrollHeight = this.ID.clientHeight - this.frd.clientHeight, this.frdHeight = this.frd.clientHeight, this.conHeight = this.ID.clientHeight, this.lastMoveTime = 0,//一下是缓动参数 this.lastMoveStart = 0, stopInertiaMove = false;//停止缓动滚动 this.init();}TouchScroll.prototype={ init: function(){ var that = this; that.ID.addEventListener('touchstart', function(e){ that.start(e); }); that.ID.addEventListener('touchmove', function(e){ that.move(e); }); that.ID.addEventListener('touchend', function(e){ that.end(e); }); }, start: function(e){ var that = this; document.addEventListener('touchmove',function(ev){ ev.preventDefault(); }); that.lastY = that.startY = e.targetTouches[0].pageY; //下面是缓动 that.lastMoveStart = that.lastY; that.lastMoveTime = Date.now(); that.stopInertiaMove = true; }, move: function(e){ var that = this; var nowY = e.targetTouches[0].pageY; var changeY = nowY - that.lastY; that.sTop = parseInt(that.ID.style.top) + changeY if (that.sTop >= 0) {that.sTop = 0}else if(Math.abs(that.sTop) > that.scrollHeight){ console.log(-(that.scrollHeight)); that.sTop = -(that.scrollHeight); }; that.ID.style.top = that.sTop + "px"; //console.log(this.frd.style.top); that.lastY = nowY; //下面是缓动 var nowTime = Date.now(); that.stopInertiaMove = true; if(nowTime - that.lastMoveTime >300){ that.lastMoveTime = nowTime; that.lastMoveStart = that.lastY; } }, end: function(e){ var that = this; document.removeEventListener('touchmove',function(ev){ ev.preventDefault(); }); var nowY = e.changedTouches[0].pageY;//touchend事件不存在targetTouches和touches var changeY = nowY - this.lastY; var contentY = parseInt(this.ID.style.top) + changeY; this.ID.style.top = contentY + "px"; this.lastY = nowY; //下面缓动 var nowTime = Date.now(); var v = (nowY - that.lastMoveStart)/(nowTime - that.lastMoveTime);//最后一划平均速度 console.log(v) that.stopInertiaMove = false; (function(v,startTime,contentY){ var updown = v>0?-1 :1;//加速度方向正数向上,负数向下 var everyidle = updown*0.0006;//每次消耗时间 var tozerotime = v/everyidle;//速度到0需要多少时间(多少次) var distance = v * tozerotime / 2;//移动距离(缓动变慢至0距离减半) function inertiaMove(){ if (that.stopInertiaMove) { return}; var theTime = Date.now(); var t = theTime - startTime;//缓动时间差 var nowV = v + t*everyidle; console.log(t+'时间') console.log(updown+'方向'); console.log(nowV+'变化后距离'); console.log(everyidle+'每次消耗'); console.log(updown*nowV+'判断结束') // 速度方向变化表示速度达到0了 if (updown*nowV > 0) { console.log('速度到0结束') return; } var moveY = (v + nowV)/2 * t;//每次在时间内的平均速度乘以时间得到移动距离 that.ID.style.top = (contentY + moveY) + "px"; console.log(contentY + moveY); setTimeout(inertiaMove, 10); } inertiaMove(); })(v,nowTime,contentY)//nowTime是触发end的时间作为缓动开始时间 }}window.TouchScroll = TouchScroll;