Skip to content

Instantly share code, notes, and snippets.

@vishnusomanus
Created June 10, 2019 11:35
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 vishnusomanus/d0a494c35946f2bdc0b359c774286573 to your computer and use it in GitHub Desktop.
Save vishnusomanus/d0a494c35946f2bdc0b359c774286573 to your computer and use it in GitHub Desktop.
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('cal');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.changedTouches[0].screenX;
touchstartY = event.changedTouches[0].screenY;
}, false);
gesuredZone.addEventListener('touchend', function(event) {
touchendX = event.changedTouches[0].screenX;
touchendY = event.changedTouches[0].screenY;
handleGesure();
}, false);
function handleGesure() {
var swiped = [];
if (touchendX < touchstartX) {
swiped.push('left');
}
if (touchendX > touchstartX) {
swiped.push('right');
}
if (touchendY < touchstartY) {
swiped.push('down');
}
if (touchendY > touchstartY) {
swiped.push('left');
}
if (touchendY == touchstartY) {
swiped.push('tap');
}
//console.log(swiped);
if(swiped[0] == "left") jQuery('.btn.btn-next').click();
if(swiped[0] == "right") jQuery('.btn.btn-prev').click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment