From 4e70cf8126e7e6bd3667479efeecc348dec7e6c0 Mon Sep 17 00:00:00 2001 From: Calyhre Date: Wed, 18 Jun 2014 14:18:08 +0200 Subject: [PATCH 1/2] Add ability to prevent swipe for specific elements --- js/reveal.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/reveal.js b/js/reveal.js index 6d98679..b4cb17f 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3482,6 +3482,8 @@ */ function onTouchStart( event ) { + if(preventSwipe(event.target)) return true; + touch.startX = event.touches[0].clientX; touch.startY = event.touches[0].clientY; touch.startCount = event.touches.length; @@ -3505,6 +3507,8 @@ */ function onTouchMove( event ) { + if(preventSwipe(event.target)) return true; + // Each touch should only trigger one action if( !touch.captured ) { onUserInput( event ); @@ -3786,6 +3790,15 @@ } + function preventSwipe(target) { + while( target && typeof target.hasAttribute == 'function' ) { + if(target.hasAttribute('prevent-swipe')) return true; + target = target.parentNode; + } + + return false; + } + // --------------------------------------------------------------------// // ------------------------ PLAYBACK COMPONENT ------------------------// From ed8d90bc58b811a921cdad53fd6d418be8bb9765 Mon Sep 17 00:00:00 2001 From: Calyhre Date: Wed, 18 Jun 2014 14:23:42 +0200 Subject: [PATCH 2/2] Fix tests --- js/reveal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/reveal.js b/js/reveal.js index b4cb17f..f844456 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3791,7 +3791,7 @@ } function preventSwipe(target) { - while( target && typeof target.hasAttribute == 'function' ) { + while( target && typeof target.hasAttribute === 'function' ) { if(target.hasAttribute('prevent-swipe')) return true; target = target.parentNode; }