Skip to content

Instantly share code, notes, and snippets.

@xthecapx
Last active November 3, 2015 20:17
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 xthecapx/b385d86e794bdb148ec9 to your computer and use it in GitHub Desktop.
Save xthecapx/b385d86e794bdb148ec9 to your computer and use it in GitHub Desktop.
Swipe events with Javascript
$('element').on('wheel', function(e){
var eo = e.originalEvent;
if(Math.abs(eo.wheelDeltaY) < 10 && Math.abs(eo.wheelDeltaX) > 2){
e.preventDefault();
if(eo.wheelDeltaX < -100){
// swipe left
}
if(eo.wheelDeltaX > 100){
// swipe right
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment