diff options
Diffstat (limited to 'js/reveal.js')
-rw-r--r-- | js/reveal.js | 163 |
1 files changed, 72 insertions, 91 deletions
diff --git a/js/reveal.js b/js/reveal.js index c7860ad..e1cd623 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -353,17 +353,15 @@ var Reveal = (function(){ createSingletonNode( dom.wrapper, 'div', 'pause-overlay', null ); // Cache references to elements - if ( config.controls ) { - dom.controls = document.querySelector( '.reveal .controls' ); + dom.controls = document.querySelector( '.reveal .controls' ); - // There can be multiple instances of controls throughout the page - dom.controlsLeft = toArray( document.querySelectorAll( '.navigate-left' ) ); - dom.controlsRight = toArray( document.querySelectorAll( '.navigate-right' ) ); - dom.controlsUp = toArray( document.querySelectorAll( '.navigate-up' ) ); - dom.controlsDown = toArray( document.querySelectorAll( '.navigate-down' ) ); - dom.controlsPrev = toArray( document.querySelectorAll( '.navigate-prev' ) ); - dom.controlsNext = toArray( document.querySelectorAll( '.navigate-next' ) ); - } + // There can be multiple instances of controls throughout the page + dom.controlsLeft = toArray( document.querySelectorAll( '.navigate-left' ) ); + dom.controlsRight = toArray( document.querySelectorAll( '.navigate-right' ) ); + dom.controlsUp = toArray( document.querySelectorAll( '.navigate-up' ) ); + dom.controlsDown = toArray( document.querySelectorAll( '.navigate-down' ) ); + dom.controlsPrev = toArray( document.querySelectorAll( '.navigate-prev' ) ); + dom.controlsNext = toArray( document.querySelectorAll( '.navigate-next' ) ); } @@ -491,13 +489,8 @@ var Reveal = (function(){ dom.wrapper.setAttribute( 'data-transition-speed', config.transitionSpeed ); dom.wrapper.setAttribute( 'data-background-transition', config.backgroundTransition ); - if( dom.controls ) { - dom.controls.style.display = ( config.controls && dom.controls ) ? 'block' : 'none'; - } - - if( dom.progress ) { - dom.progress.style.display = ( config.progress && dom.progress ) ? 'block' : 'none'; - } + dom.controls.style.display = config.controls ? 'block' : 'none'; + dom.progress.style.display = config.progress ? 'block' : 'none'; if( config.rtl ) { dom.wrapper.classList.add( 'rtl' ); @@ -586,16 +579,14 @@ var Reveal = (function(){ dom.progress.addEventListener( 'click', onProgressClicked, false ); } - if ( config.controls && dom.controls ) { - [ 'touchstart', 'click' ].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 ); } ); - } ); - } + [ 'touchstart', 'click' ].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 ); } ); + } ); } @@ -624,16 +615,14 @@ var Reveal = (function(){ dom.progress.removeEventListener( 'click', onProgressClicked, false ); } - if ( config.controls && dom.controls ) { - [ 'touchstart', 'click' ].forEach( function( eventName ) { - dom.controlsLeft.forEach( function( el ) { el.removeEventListener( eventName, onNavigateLeftClicked, false ); } ); - dom.controlsRight.forEach( function( el ) { el.removeEventListener( eventName, onNavigateRightClicked, false ); } ); - dom.controlsUp.forEach( function( el ) { el.removeEventListener( eventName, onNavigateUpClicked, false ); } ); - dom.controlsDown.forEach( function( el ) { el.removeEventListener( eventName, onNavigateDownClicked, false ); } ); - dom.controlsPrev.forEach( function( el ) { el.removeEventListener( eventName, onNavigatePrevClicked, false ); } ); - dom.controlsNext.forEach( function( el ) { el.removeEventListener( eventName, onNavigateNextClicked, false ); } ); - } ); - } + [ 'touchstart', 'click' ].forEach( function( eventName ) { + dom.controlsLeft.forEach( function( el ) { el.removeEventListener( eventName, onNavigateLeftClicked, false ); } ); + dom.controlsRight.forEach( function( el ) { el.removeEventListener( eventName, onNavigateRightClicked, false ); } ); + dom.controlsUp.forEach( function( el ) { el.removeEventListener( eventName, onNavigateUpClicked, false ); } ); + dom.controlsDown.forEach( function( el ) { el.removeEventListener( eventName, onNavigateDownClicked, false ); } ); + dom.controlsPrev.forEach( function( el ) { el.removeEventListener( eventName, onNavigatePrevClicked, false ); } ); + dom.controlsNext.forEach( function( el ) { el.removeEventListener( eventName, onNavigateNextClicked, false ); } ); + } ); } @@ -778,7 +767,7 @@ var Reveal = (function(){ */ function hideAddressBar() { - if( /iphone|ipod|android/gi.test( navigator.userAgent ) && !/crios/gi.test( navigator.userAgent ) ) { + if( isMobileDevice ) { // Events that should trigger the address bar to hide window.addEventListener( 'load', removeAddressBar, false ); window.addEventListener( 'orientationchange', removeAddressBar, false ); @@ -792,7 +781,8 @@ var Reveal = (function(){ */ function removeAddressBar() { - if( window.orientation === 0 ) { + // Portrait and not Chrome for iOS + if( window.orientation === 0 && !/crios/gi.test( navigator.userAgent ) ) { document.documentElement.style.overflow = 'scroll'; document.body.style.height = '120%'; } @@ -1156,7 +1146,7 @@ var Reveal = (function(){ var depth = window.innerWidth < 400 ? 1000 : 2500; dom.wrapper.classList.add( 'overview' ); - dom.wrapper.classList.remove( 'exit-overview' ); + dom.wrapper.classList.remove( 'overview-deactivating' ); clearTimeout( activateOverviewTimeout ); clearTimeout( deactivateOverviewTimeout ); @@ -1164,7 +1154,7 @@ var Reveal = (function(){ // Not the pretties solution, but need to let the overview // class apply first so that slides are measured accurately // before we can position them - activateOverviewTimeout = setTimeout( function(){ + activateOverviewTimeout = setTimeout( function() { var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ); @@ -1241,25 +1231,19 @@ var Reveal = (function(){ // Temporarily add a class so that transitions can do different things // depending on whether they are exiting/entering overview, or just // moving from slide to slide - dom.wrapper.classList.add( 'exit-overview' ); + dom.wrapper.classList.add( 'overview-deactivating' ); deactivateOverviewTimeout = setTimeout( function () { - dom.wrapper.classList.remove( 'exit-overview' ); - }, 10); + dom.wrapper.classList.remove( 'overview-deactivating' ); + }, 1 ); // Select all slides - var slides = toArray( document.querySelectorAll( SLIDES_SELECTOR ) ); - - for( var i = 0, len = slides.length; i < len; i++ ) { - var element = slides[i]; - - element.style.display = ''; - + toArray( document.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) { // Resets all transforms to use the external styles - transformElement( element, '' ); + transformElement( slide, '' ); - element.removeEventListener( 'click', onOverviewSlideClicked, true ); - } + slide.removeEventListener( 'click', onOverviewSlideClicked, true ); + } ); slide( indexh, indexv ); @@ -1792,48 +1776,45 @@ var Reveal = (function(){ */ function updateControls() { - if ( config.controls && dom.controls ) { - - var routes = availableRoutes(); - var fragments = availableFragments(); - - // Remove the 'enabled' class from all directions - dom.controlsLeft.concat( dom.controlsRight ) - .concat( dom.controlsUp ) - .concat( dom.controlsDown ) - .concat( dom.controlsPrev ) - .concat( dom.controlsNext ).forEach( function( node ) { - node.classList.remove( 'enabled' ); - node.classList.remove( 'fragmented' ); - } ); + var routes = availableRoutes(); + var fragments = availableFragments(); + + // Remove the 'enabled' class from all directions + dom.controlsLeft.concat( dom.controlsRight ) + .concat( dom.controlsUp ) + .concat( dom.controlsDown ) + .concat( dom.controlsPrev ) + .concat( dom.controlsNext ).forEach( function( node ) { + node.classList.remove( 'enabled' ); + node.classList.remove( 'fragmented' ); + } ); - // Add the 'enabled' class to the available routes - if( routes.left ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'enabled' ); } ); - if( routes.right ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'enabled' ); } ); - if( routes.up ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'enabled' ); } ); - if( routes.down ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'enabled' ); } ); + // Add the 'enabled' class to the available routes + if( routes.left ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'enabled' ); } ); + if( routes.right ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'enabled' ); } ); + if( routes.up ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'enabled' ); } ); + if( routes.down ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'enabled' ); } ); - // Prev/next buttons - if( routes.left || routes.up ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'enabled' ); } ); - if( routes.right || routes.down ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'enabled' ); } ); + // Prev/next buttons + if( routes.left || routes.up ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'enabled' ); } ); + if( routes.right || routes.down ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'enabled' ); } ); - // Highlight fragment directions - if( currentSlide ) { + // Highlight fragment directions + if( currentSlide ) { - // Always apply fragment decorator to prev/next buttons - if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); - if( fragments.next ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); + // Always apply fragment decorator to prev/next buttons + if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); + if( fragments.next ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); - // Apply fragment decorators to directional buttons based on - // what slide axis they are in - if( isVerticalSlide( currentSlide ) ) { - if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); - if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); - } - else { - if( fragments.prev ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); - if( fragments.next ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); - } + // Apply fragment decorators to directional buttons based on + // what slide axis they are in + if( isVerticalSlide( currentSlide ) ) { + if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); + if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); + } + else { + if( fragments.prev ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); + if( fragments.next ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); } } |