Skip to content

Instantly share code, notes, and snippets.

@dgalarza
Created June 20, 2012 16:11
Show Gist options
  • Save dgalarza/2960713 to your computer and use it in GitHub Desktop.
Save dgalarza/2960713 to your computer and use it in GitHub Desktop.
Swiping example
var start_location, end_location
$portfolio_modal = $('#portfolio-modal');
$portfolio_modal.bind('touchstart', function(e) {
start_location = e.originalEvent.targetTouches[0].pageX;
return end_location = 0;
});
$portfolio_modal.bind('touchmove', function(e) {
return end_location = e.originalEvent.targetTouches[0].pageX - start_location;
});
$portfolio_modal.bind('touchend', function(e) {
if (Math.abs(end_location) < 200) return;
if (end_location > 0) {
return prev_item();
} else {
return next_item();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment