1. 程式人生 > >手機端和pc端點選及觸控事件

手機端和pc端點選及觸控事件

touchstart事件:當手指觸控式螢幕幕時候觸發,即使已經有一個手指放在螢幕上也會觸發。 

touchmove事件:當手指在螢幕上滑動的時候連續地觸發。在這個事件發生期間,呼叫preventDefault()事件可以阻止滾動。 

touchend事件:當手指從螢幕上離開的時候觸發。 

touchcancel事件:當系統停止跟蹤觸控的時候觸發。

 initTouchEvents: function () {
         if (isPC()) {
                this.touchstart = "mousedown";
                this.touchmove = "mousemove";
                this.touchend = "mouseup";
           }
   }


注:(1)pc端的用法為mosemove(mouseover),mouseleave;

(2)click和mousedown,mouseup不可同時對同一元素使用,click包含二者