leohxj
9/13/2013 - 8:04 AM

原生JS判断触摸屏事件

原生JS判断触摸屏事件

var isTouch = 'ontouchstart' in document.documentElement;
    var interaction = {
        tap: isTouch ? "touchend" : "click",
        down: isTouch ? "touchstart" : "mousedown",
        move: isTouch ? "touchmove" : "mousemove",
        stop: isTouch ? "touchend touchcancel" : "mouseup",
        hover: isTouch ? "touchstart" : "mouseover"
    };