移动端监听上滑下滑(判断元素是否滚动到底部)
touchUp(){ var startY = 0; let that = this; document.addEventListener("touchstart",function(e){ startY = e.changedTouches[0].pageY; },false); document.addEventListener("touchmove",function(e){ var endY = e.changedTouches[0].pageY; var changeVal = endY - startY; if(endY < startY){//向上滑 // console.log("向上滑"); that.showSearchFlag = false }else if(endY > startY){//向下滑 // console.log("向下滑"); that.showSearchFlag = true }else{ // console.log("没有偏移"); } // 获取屏幕高度 var a = document.body.scrollTop || document.documentElement.scrollTop;; //滚动条的高度 var b =document.documentElement.clientHeight //可视区的高度 var c = $(‘#listIndex‘).height(); //文档的总高度 if(a b >= c){ //表示浏览器已经到达最底部 that.showSearchFlag = true } },false); },
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/yidong/18957.html