關於touch事件

var starty=0;//觸摸開始var movey=0;//觸摸結束var ends=0;//計算結果divs.addEventListener("touchstart", function(e) {    var touch = e.touches[0]; //獲取第一個觸點    starty = Number(touch.pageY); //頁面觸點Y座標    });divs.addEventListener("touchmove", function(e) {});divs.addEventListener("touchend", function(e) {    movey=e.changedTouches[0].pageY    ends=starty-movey;    if(ends<-100){        //這裏邊是你要進行的操做     }});在獲取的時候要麼用原生 要麼用jq  不要混合使用 touch事件在 iOS上存在問題在使用的時候須要慎重
相關文章
相關標籤/搜索