diff options
author | Bartek Szopka <bartek.szopka+github@gmail.com> | 2012-02-15 20:39:45 +0100 |
---|---|---|
committer | Bartek Szopka <bartek.szopka+github@gmail.com> | 2012-02-15 21:17:26 +0100 |
commit | db5857afdafea7e7fd4f35be9c6155fa36c33956 (patch) | |
tree | 8c41adc9952271bc072740b355a3750f1d653268 | |
parent | cfe6448594157e3c5ce2383525ce6f23f0a07bb3 (diff) | |
download | impress.js-db5857afdafea7e7fd4f35be9c6155fa36c33956.tar.gz |
impressive touch support
-rw-r--r-- | js/impress.js | 18 |
1 files changed, 18 insertions, 0 deletions
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); |