contBox里面的内容改成这样:
<div id="contBox"> <div style="height: 50px; position: absolute; top: 0; left: 0;">固定的内容</div> <div style=" position: absolute; top: 50px; bottom: 0; left: 0; width: 100%; overflow: auto;"> <!--这里放任何想放的内容--> <div style="height: 150px;background: red;">上滑这个红色块试试</div> <div style="height: 150px;background: orange;"></div> <div style="height: 150px;background: yellow;"></div> <div style="height: 150px;background: green;"></div> <div style="height: 150px;background: blue;"></div> <div style="height: 150px;background: purple;"></div> </div> </div>
我在touchend中加了个判断
touchend: function(e) {
var _this = this;
if (this.state == "scroll") {
return;
}
this.y = this.direction == "toBottom" ? this.bottom : this.top;
this.height = this.h - this.y;
this.opacity = this.direction == "toBottom" ? 0 : this.opacityMax;
this.setDom("end");
// 加了个判断
if (!this.direction) {
this.direction = "toBottom"
this.contEl.style.overflow = "auto";
} else if (this.direction == "toBottom") {
this.direction = "toTop"
} else {
this.direction = "toBottom"
this.contEl.style.overflow = "auto";
}
// end
this.ifTouch = false;
},