Created
May 14, 2013 16:16
-
-
Save cwmanning/5577239 to your computer and use it in GitHub Desktop.
touch support stash
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
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