Skip to content

Instantly share code, notes, and snippets.

@leohxj
Created September 13, 2013 08:04
Show Gist options
  • Select an option

  • Save leohxj/6547928 to your computer and use it in GitHub Desktop.

Select an option

Save leohxj/6547928 to your computer and use it in GitHub Desktop.
原生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"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment