I want to detect if i am scrolling but only after I\'ve scrolled a certain distance from my current location. When I stop scrolling, this distance resets to the current location
with this i was able to get the swipe up and down...
i add a flag so it only run once that fix the problem of keep swiping. thanks to https://css-tricks.com/forums/topic/detect-vertical-direction-of-jquery-touchmove/
currentY:
var swipe = false,
var lastY,
timer;
$(document).bind('touchstart', function(e) {
lastY = e.originalEvent.touches ? e.originalEvent.touches[0].pageY : e.pageY;
console.log(lastY);
});
$(document).bind('touchmove mousemove', function(e) {
var currentY = e.originalEvent.touches ? e.originalEvent.touches[0].pageY : e.pageY;
if(!swipe){
if (Math.abs(currentY-lastY) < 50) { return; }
swipe = true;
if (currentY > lastY) {
console.log('down');
} else {
console.log('up');
}
}
}).on('touchend', function(){
swipe = false;
});