listen for touch + click on all devices except android
parent
213c8d1354
commit
57844ad827
13
js/reveal.js
13
js/reveal.js
|
@ -909,13 +909,24 @@
|
|||
}
|
||||
}
|
||||
|
||||
var eventName = features.touch ? 'touchstart' : 'click';
|
||||
// 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 ); } );
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue