From 049880dba3062bd8ecb91ad0bd4fd0543d03a2dd Mon Sep 17 00:00:00 2001
From: akiersky <akiersky@gmail.com>
Date: Wed, 30 May 2012 11:11:34 -0300
Subject: [PATCH] fixed bug in swipe gesture interacting with links.

---
 js/reveal.js | 45 ++++++++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/js/reveal.js b/js/reveal.js
index 7da9935..0debffd 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -26,7 +26,7 @@ var Reveal = (function(){
 			rollingLinks: true,
 			transition: 'default',
 			theme: 'default',
-			swipeDistance: 30
+			swipeDist: 30
 		},
 
 		// Slides may hold a data-state attribute which we pick up and apply 
@@ -241,22 +241,15 @@ var Reveal = (function(){
 	 var touchStart = {}
 	 var gesture = false;
 	function onDocumentTouchStart( event ) {
-		// We're only interested in one point taps
-		if (event.touches.length === 1) {
-			// Never prevent taps on anchors and images
-			if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
-				return;
-			}
-			
-			event.preventDefault();
 			
-			touchStart = {
-				x: event.touches[0].clientX,
-				y: event.touches[0].clientY
-			};
-			
-			slide();
-		}
+		touchStart = {
+			x: event.touches[0].clientX,
+			y: event.touches[0].clientY
+		};
+		if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
+			} else { 
+				event.preventDefault(); 
+			}
 	}
 	
 	function onDocumentTouchMove( event ) {
@@ -268,27 +261,28 @@ var Reveal = (function(){
 					x: event.touches[0].clientX,
 					y: event.touches[0].clientY
 				};
-			if((touch.x - touchStart.x) > config.swipeDistance){
+			if((touch.x - touchStart.x) > config.swipeDist){
 				gesture = true;
 				navigateLeft();
-			} else if((touch.x - touchStart.x) < -config.swipeDistance){
+			} else if((touch.x - touchStart.x) < -config.swipeDist){
 				gesture = true;
 				navigateRight();
-			} else if((touch.y - touchStart.y) > config.swipeDistance){
+			} else if((touch.y - touchStart.y) > config.swipeDist){
 				gesture = true;
 				navigateUp();
-			} else if((touch.y - touchStart.y) < -config.swipeDistance){
+			} else if((touch.y - touchStart.y) < -config.swipeDist){
 				gesture = true;
 				navigateDown();
 			}
 		}
 	}
 	function onDocumentTouchEnd( event ) {
-		
-		event.preventDefault();
-		
-		if(!gesture){//only check for control tap if no gesture is performed
-		
+		if(!gesture){
+			// Never prevent taps on anchors and images
+			if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
+				return;
+			}
+			
 			// Define the extent of the areas that may be tapped
 			// to navigate
 			var wt = window.innerWidth * 0.3;
@@ -308,6 +302,7 @@ var Reveal = (function(){
 			}
 		}
 		gesture = false;
+		event.preventDefault();
 	}
 
 	/**
-- 
GitLab