diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2014-07-06 14:31:10 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2014-07-06 14:31:10 +0200 |
commit | 57844ad827523be8ca8992837a5a591c472d77a7 (patch) | |
tree | 243affd91fdb3d605300a1f4dc286c1397bab6bd /js | |
parent | 213c8d13541f3ac4c68098a6528d1bdcc716ab32 (diff) | |
download | fosdem-2018-presentation-57844ad827523be8ca8992837a5a591c472d77a7.tar fosdem-2018-presentation-57844ad827523be8ca8992837a5a591c472d77a7.tar.gz |
listen for touch + click on all devices except android
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/js/reveal.js b/js/reveal.js index 270bf63..b4065d6 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -909,13 +909,24 @@ } } - var eventName = features.touch ? 'touchstart' : 'click'; - dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } ); - dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } ); - dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } ); - dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } ); - dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } ); - dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } ); + // Listen to both touch and click events, in case the device + // supports both + var pointerEvents = [ 'touchstart', 'click' ]; + + // Only support touch for Android, fixes double navigations in + // stock browser + if( navigator.userAgent.match( /android/gi ) ) { + pointerEvents = [ 'touchstart' ]; + } + + pointerEvents.forEach( function( eventName ) { + dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } ); + dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } ); + dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } ); + dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } ); + dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } ); + dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } ); + } ); } |