dom.wrapper = document.querySelector( '.reveal' );
dom.progress = document.querySelector( '.reveal .progress' );
dom.progressbar = document.querySelector( '.reveal .progress span' );
- dom.controls = document.querySelector( '.reveal .controls' );
- dom.controlsLeft = document.querySelector( '.reveal .controls .left' );
- dom.controlsRight = document.querySelector( '.reveal .controls .right' );
- dom.controlsUp = document.querySelector( '.reveal .controls .up' );
- dom.controlsDown = document.querySelector( '.reveal .controls .down' );
+
+ if (config.controls) {
+ dom.controls = document.querySelector( '.reveal .controls' );
+ dom.controlsLeft = document.querySelector( '.reveal .controls .left' );
+ dom.controlsRight = document.querySelector( '.reveal .controls .right' );
+ dom.controlsUp = document.querySelector( '.reveal .controls .up' );
+ dom.controlsDown = document.querySelector( '.reveal .controls .down' );
+ }
addEventListeners();
config.transition = 'linear';
}
- if( config.controls ) {
+ if( config.controls && dom.controls ) {
dom.controls.style.display = 'block';
}
document.addEventListener( 'touchmove', onDocumentTouchMove, false );
document.addEventListener( 'touchend', onDocumentTouchEnd, false );
window.addEventListener( 'hashchange', onWindowHashChange, false );
-
- dom.controlsLeft.addEventListener( 'click', preventAndForward( navigateLeft ), false );
- dom.controlsRight.addEventListener( 'click', preventAndForward( navigateRight ), false );
- dom.controlsUp.addEventListener( 'click', preventAndForward( navigateUp ), false );
- dom.controlsDown.addEventListener( 'click', preventAndForward( navigateDown ), false );
+
+ if (dom.controls) {
+ dom.controlsLeft.addEventListener( 'click', preventAndForward( navigateLeft ), false );
+ dom.controlsRight.addEventListener( 'click', preventAndForward( navigateRight ), false );
+ dom.controlsUp.addEventListener( 'click', preventAndForward( navigateUp ), false );
+ dom.controlsDown.addEventListener( 'click', preventAndForward( navigateDown ), false );
+ }
}
function removeEventListeners() {
document.removeEventListener( 'touchend', onDocumentTouchEnd, false );
window.removeEventListener( 'hashchange', onWindowHashChange, false );
- dom.controlsLeft.removeEventListener( 'click', preventAndForward( navigateLeft ), false );
- dom.controlsRight.removeEventListener( 'click', preventAndForward( navigateRight ), false );
- dom.controlsUp.removeEventListener( 'click', preventAndForward( navigateUp ), false );
- dom.controlsDown.removeEventListener( 'click', preventAndForward( navigateDown ), false );
+ if (dom.controls) {
+ dom.controlsLeft.removeEventListener( 'click', preventAndForward( navigateLeft ), false );
+ dom.controlsRight.removeEventListener( 'click', preventAndForward( navigateRight ), false );
+ dom.controlsUp.removeEventListener( 'click', preventAndForward( navigateUp ), false );
+ dom.controlsDown.removeEventListener( 'click', preventAndForward( navigateDown ), false );
+ }
}
/**
* Updates the state and link pointers of the controls.
*/
function updateControls() {
+ if (!dom.controls) return;
+
var routes = availableRoutes();
// Remove the 'enabled' class from all directions