Skip to content

Instantly share code, notes, and snippets.

@cwmanning
Created May 14, 2013 16:16
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 cwmanning/5577239 to your computer and use it in GitHub Desktop.
Save cwmanning/5577239 to your computer and use it in GitHub Desktop.
touch support stash
this.$slide
.on('touchstart', function(e) {
e.preventDefault();
})
.on('touchend', function(e) {
console.log(e)
var slide = $(e.currentTarget);
var touchEvent = e.originalEvent || e;
var targetX = e.target.x;
console.log(e.target.x);
console.log(touchEvent);
if (touchEvent.changedTouches.length == 1) {
var touch = touchEvent.changedTouches[0];
//console.log('the touch', touch);
console.log('the touch X', touch.pageX);
var diff = targetX - touch.pageX;
console.log(diff);
if (Math.abs(diff) > this.swipeThreshold) {
diff > 0 ? this.prev() : this.next();
}
}
}.bind(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment