listen for touch + click on all devices except android
This commit is contained in:
parent
213c8d1354
commit
57844ad827
25
js/reveal.js
25
js/reveal.js
|
@ -909,13 +909,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventName = features.touch ? 'touchstart' : 'click';
|
// Listen to both touch and click events, in case the device
|
||||||
dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } );
|
// supports both
|
||||||
dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } );
|
var pointerEvents = [ 'touchstart', 'click' ];
|
||||||
dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } );
|
|
||||||
dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } );
|
// Only support touch for Android, fixes double navigations in
|
||||||
dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } );
|
// stock browser
|
||||||
dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } );
|
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