Skip to content

Instantly share code, notes, and snippets.

@c3ry5
Created June 18, 2013 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save c3ry5/5806252 to your computer and use it in GitHub Desktop.
Save c3ry5/5806252 to your computer and use it in GitHub Desktop.
To detect if i device supports touch events with a jquery scroll function
var isTouch = function () {
return 'ontouchend' in document;
}
/* unbind first to prevent double binding of action */
$(window).unbind(isTouch() ? 'touchmove' : 'scroll');
$(window).bind(isTouch() ? 'touchmove' : 'scroll', function(){
/*callback function*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment