From db5857afdafea7e7fd4f35be9c6155fa36c33956 Mon Sep 17 00:00:00 2001 From: Bartek Szopka Date: Wed, 15 Feb 2012 20:39:45 +0100 Subject: [PATCH] impressive touch support --- js/impress.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/impress.js b/js/impress.js index 0e810a6..a6be86b 100644 --- a/js/impress.js +++ b/js/impress.js @@ -382,5 +382,23 @@ } }, false); + // touch handler to detect taps on the left and right side of the screen + document.addEventListener("touchstart", function ( event ) { + if (event.touches.length === 1) { + var x = event.touches[0].clientX, + width = window.innerWidth * 0.3, + result = null; + + if ( x < width ) { + result = impress().prev(); + } else if ( x > window.innerWidth - width ) { + result = impress().next(); + } + + if (result) { + event.preventDefault(); + } + } + }, false); })(document, window);