移动端向上滑动整个屏幕

监听touchStart,touchEnd,使用jquery的animate
touchStart(e) {
console.log("开始");
this.startY = e.targetTouches[0].clientY;
},
touchEnd(e) {
// e.preventDefault();
let y = Math.abs(this.startY - e.changedTouches[0].clientY) > 30;
console.log("结束:" + y);
if (y) {
$("html,body").animate(
{ scrollTop: 2 * window.innerHeight + 20 * 2 + "px" },
500
);
}
}
posted on 2019-06-27 15:53  IT-HourseMan  阅读(708)  评论(0编辑  收藏  举报