Skip to content

Instantly share code, notes, and snippets.

@HashandSalt
Created December 30, 2019 12:51
Show Gist options
  • Save HashandSalt/56707ddf351b8d7d111b70ea2688d6ed to your computer and use it in GitHub Desktop.
Save HashandSalt/56707ddf351b8d7d111b70ea2688d6ed to your computer and use it in GitHub Desktop.
gestureZone.addEventListener('touchstart', function(event) {
touchstartX = event.changedTouches[0].screenX;
}, false);
gestureZone.addEventListener('touchend', function(event) {
touchendX = event.changedTouches[0].screenX;
handleGesture();
}, false);
function handleGesture() {
if (touchendX < touchstartX && Math.abs(touchendX - touchstartX) > 150) {
window.location.replace(prev.href)
}
if (touchendX > touchstartX && Math.abs(touchendX - touchstartX) > 150) {
window.location.replace(next.href)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment