haocker
haocker
  • 发布:2018-01-11 02:14
  • 更新:2018-01-18 13:55
  • 阅读:2260

【报Bug】触摸事件BUG

分类:HTML5+

详细问题描述
01-11 02:04:17.620 31126-31126/com.HBuilder.integrate D/ViewRootImpl: cancle motionEvent because of threeGesture detecting
[IDE版本]
8.9.1.201712121728

附件
[代码片段]

/*  
                 滑动开始  
                 *   
                 * */  
                //跟随手势  
                var moveframme = function(x) {  
                     console.log(x)  
                    //mui(".right")[0].style.cssText="transform:translate3d("+x+"px,0px,0px)";  
                    //mui(".mask")[0].style.opacity = x / 400;  
                    mui(".ManKuo-main")[0].style.cssText = "transform:translate3d(" + x + "px,0px,0px)";  
                }  
                //左滑  
                var moveleft = function() {  
                    console.log("leftgo")  
                    mui.back = function() {  
                        mankuo.quit();  
                    };  
                    mui(".ManKuo-main")[0].style.cssText = "transform:translate3d(0px,0px,0px)";  
                    mui(".ManKuo-main")[0].classList.remove("active");  
                    //mui(".mask")[0].style.opacity = 0;  
                }  
                //右滑  
                var moveright = function() {  
                    console.log("rightgo")  
                    mui.back = function() {  
                        moveleft();  
                    };  
                    //mui(".right")[0].style.cssText="transform:translate3d("+document.body.clientWidth+"px,0px,0px)";  
                    mui(".ManKuo-main")[0].style.cssText = "transform:translate3d(" + document.body.clientWidth + "px,0px,0px)";  
                    mui(".ManKuo-main")[0].classList.add("active");  
                }  
                //右滑事件  
                mui('html').on('swiperight', 'body', function() {  
                    moveright();  
                })  
                //左滑事件  
                mui('html').on('swipeleft', 'body', function() {  
                    moveleft();  
                })  
                //触摸开始事件  
                mui("html").on("touchstart", "body", function() {  
                    event.preventDefault()  
                    var touch = event.touches[0];//获取触摸对象  
                    self.tsx = touch.clientX;//获取触摸起始横坐标  
                    self.tsY = touch.clientY;//获取纵坐标  
                    self.tdir = 0;//滑动方向 1为右,-1为左  
                    self.istouch = false;//触摸状态  
                    self.mi = 0;//移动次数  
                    self.r = mui('.ManKuo-main')[0].classList.contains("active");  
                })  
                //触摸移动事件  
                mui("html").on("touchmove", "body", function() {  
                    event.preventDefault()  
                    //判断是否有列表向左滑出,0为没有  
                    if(mui('.mui-selected').length == 0) {  
                        self.mi++;//移动次数,移动一次自增  
                        var touch = event.touches[0];//触摸对象  
                        //第十次时判断是否横向滑动,是横向滑动则触摸状态为真  
                        if(self.mi == 10 && Math.abs(touch.clientX - self.tsx) > Math.abs(self.tsY - touch.clientY)) {  
                            //console.log(Math.abs(touch.clientX - self.tsx) - Math.abs(self.tsY - touch.clientY))  
                            self.istouch = true;  
                        }  
                        //如果当前横坐标大于起始横坐标,且触摸状态为真时执行以下操作  
                        if(touch.clientX > self.tsx && self.istouch&&!self.r) {  
                            //手势跟随  
                                moveframme(touch.clientX - self.tsx)  
                            //如果向右拖动距离大于1/6则滑动方向为右,否则为左  
                            if(touch.clientX - self.tsx > document.body.clientWidth / 6) {  
                                self.tdir = 1;  
                            }else{  
                                self.tdir = -1;  
                            }  
                        }else if(touch.clientX < self.tsx&&self.istouch&&self.r){  
                            //如果当前横坐标小于起始横坐标,且触摸状态为真时执行以下操作  
                            //手势跟随  
                                moveframme((touch.clientX - self.tsx) + document.body.clientWidth)  
                            //如果向左拖动距离大于1/6则滑动方向为左,否则为右  
                            if(self.tsx - touch.clientX > document.body.clientWidth / 6) {  
                                self.tdir = -1;  
                            }else{  
                                self.tdir = 1;  
                            }  
                        }  
                    }  

                    //self.tsx = touch.clientX;  
                })  
                //触摸结束事件  
                mui("html").on("touchend", "body", function() {  
                    event.preventDefault()  
                    if(self.tdir==1) {  
                        moveright()  
                    } else if(self.tdir==-1){  
                        moveleft()  

                    }  

                    //this.style.transition="left 0s"  
                })

[错误日志]
看附件

2018-01-11 02:14 负责人:无 分享
已邀请:
haocker

haocker (作者)

测试了一下,官方demo也有这个问题,div模式左滑或右滑

该问题目前已经被锁定, 无法添加新回复