移动端监听上滑下滑(判断元素是否滚动到底部)


        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);
        },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM