首页 > 网站 > WEB开发 > 正文

touchmove时 even 为undefined的问题

2024-04-27 15:17:56
字体:
来源:转载
供稿:网友

嗨呀  换成

e.originalEvent.targetTouches[0]

就成了!

嗨呀 最后解决的问题是 weui的picker的上下滑动  懒得找他源码所以自己做的  jq+jq mobile

html部分

<!--选择列表--><div class="choose-group">  <div class="weui-mask weui-animate-fade-in"></div>  <div class="weui-picker weui-animate-slide-up">    <div class="weui-picker__bd">      <div class="weui-picker__group">        <div class="weui-picker__mask" style="z-index: 4"></div>        <div class="weui-picker__indicator"></div>        <div class="weui-picker__content" style="transform: translate3d(0px, 102px, 0px);">          <div class="weui-picker__item">全部运维组</div>          <div class="weui-picker__item">北航运维组</div>          <div class="weui-picker__item">北理工运维组</div>          <div class="weui-picker__item">北大运维组</div>          <div class="weui-picker__item">清华运维组</div>          <div class="weui-picker__item">清华运维组</div>          <div class="weui-picker__item">清华运维组</div>          <div class="weui-picker__item">清华运维组</div>          <div class="weui-picker__item">清华运维组</div>        </div>      </div>    </div></div></div>js部分

//触摸事件var SY=null,distance=null,ct=$(".choose-group .weui-picker__content");$(".weui-picker__mask").on("touchmove", function (e) {  e.PReventDefault();  var re=ct.CSS("transform").replace(/[^0-9/-,]/g,'').split(',');  re=re[re.length-1];  var SYN=e.originalEvent.targetTouches[0].screenY;  if(SY!=SYN){    var a=parseFloat(re)+parseFloat(SYN)-parseFloat(SY);    ct.css("transform","translateY("+ a +"px)");    SY=SYN;  }}).on("touchend", function () {  SY=null;  var re=ct.css("transform").replace(/[^0-9/-,]/g,'').split(',');  re=re[re.length-1];  var n=null;//34  var arr=[];  for(var i=0;i<ct.children().length;i++){    arr[i]=102-34*i;  }  var i=0;  while(true){    if(re>=arr[0]){      moveTo(arr[0]);      break;    }else if(re<=arr[arr.length-1]){      moveTo(arr[arr.length-1]);      break;    }else if(re<=arr[i]+17&&re>arr[i]-17){      moveTo(arr[i]);      break;    }    i++;  }});function moveTo(y){  "use strict";  ct.css("transform","translateY("+ y +"px)");}嗨呀 有指教的欢迎评论~


上一篇:DES3加解密问题

下一篇:javascript 学习

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表