Skip to content

Instantly share code, notes, and snippets.

@greypants
Created October 22, 2012 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greypants/3933531 to your computer and use it in GitHub Desktop.
Save greypants/3933531 to your computer and use it in GitHub Desktop.
JS: Touch/Desktop Event Pattern
var supports_touch = 'ontouchend' in document;
var events = {
desktop: {
start : 'mousedown',
stop : 'mouseup',
move : 'mousemove',
leave : 'mouseleave',
resize : 'resize'
},
mobile: {
start : 'touchstart',
stop : 'touchend',
move : 'touchmove',
leave : 'touchleave',
resize : 'orientationchange'
}
};
events = supports_touch ? events.desktop : events.mobile;
$('.expand').bind(events.start, expandDiv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment