Created
June 18, 2013 15:18
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isTouch = function () { | |
return 'ontouchend' in document; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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