Skip to content
Snippets Groups Projects
reveal.js 88.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • 			closePreview();
    		}, false );
    
    		setTimeout( function() {
    			dom.preview.classList.add( 'visible' );
    		}, 1 );
    
    	}
    
    	/**
    	 * Closes the iframe preview window.
    	 */
    	function closePreview() {
    
    		if( dom.preview ) {
    			dom.preview.setAttribute( 'src', '' );
    			dom.preview.parentNode.removeChild( dom.preview );
    			dom.preview = null;
    		}
    
    	}
    
    
    	/**
    	 * Applies JavaScript-controlled layout rules to the
    	 * presentation.
    	 */
    	function layout() {
    
    		if( dom.wrapper && !isPrintingPDF() ) {
    
    			// Available space to scale within
    			var availableWidth = dom.wrapper.offsetWidth,
    				availableHeight = dom.wrapper.offsetHeight;
    
    			// Reduce available space by margin
    
    			availableWidth -= ( availableHeight * config.margin );
    			availableHeight -= ( availableHeight * config.margin );
    
    			// Dimensions of the content
    			var slideWidth = config.width,
    
    				slideHeight = config.height,
    				slidePadding = 20; // TODO Dig this out of DOM
    
    			// Layout the contents of the slides
    			layoutSlideContents( config.width, config.height, slidePadding );
    
    
    			// Slide width may be a percentage of available width
    			if( typeof slideWidth === 'string' && /%$/.test( slideWidth ) ) {
    				slideWidth = parseInt( slideWidth, 10 ) / 100 * availableWidth;
    			}
    
    			// Slide height may be a percentage of available height
    			if( typeof slideHeight === 'string' && /%$/.test( slideHeight ) ) {
    				slideHeight = parseInt( slideHeight, 10 ) / 100 * availableHeight;
    			}
    
    			dom.slides.style.width = slideWidth + 'px';
    			dom.slides.style.height = slideHeight + 'px';
    
    			// Determine scale of content to fit within available space
    			scale = Math.min( availableWidth / slideWidth, availableHeight / slideHeight );
    
    			// Respect max/min scale settings
    			scale = Math.max( scale, config.minScale );
    			scale = Math.min( scale, config.maxScale );
    
    			// Prefer applying scale via zoom since Chrome blurs scaled content
    			// with nested transforms
    			if( typeof dom.slides.style.zoom !== 'undefined' && !navigator.userAgent.match( /(iphone|ipod|ipad|android)/gi ) ) {
    				dom.slides.style.zoom = scale;
    			}
    			// Apply scale transform as a fallback
    			else {
    
    				transformElement( dom.slides, 'translate(-50%, -50%) scale('+ scale +') translate(50%, 50%)' );
    
    			// Select all slides, vertical and horizontal
    			var slides = toArray( document.querySelectorAll( SLIDES_SELECTOR ) );
    
    			for( var i = 0, len = slides.length; i < len; i++ ) {
    				var slide = slides[ i ];
    
    				// Don't bother updating invisible slides
    				if( slide.style.display === 'none' ) {
    					continue;
    				}
    
    				if( config.center || slide.classList.contains( 'center' ) ) {
    
    					// Vertical stacks are not centred since their section
    
    					// children will be
    					if( slide.classList.contains( 'stack' ) ) {
    						slide.style.top = 0;
    					}
    					else {
    
    						slide.style.top = Math.max( - ( getAbsoluteHeight( slide ) / 2 ) - slidePadding, -slideHeight / 2 ) + 'px';
    
    			updateProgress();
    
    	/**
    	 * Applies layout logic to the contents of all slides in
    	 * the presentation.
    	 */
    	function layoutSlideContents( width, height, padding ) {
    
    
    		// Handle sizing of elements with the 'stretch' class
    		toArray( dom.slides.querySelectorAll( 'section > .stretch' ) ).forEach( function( element ) {
    
    
    			// Determine how much vertical space we can use
    			var remainingHeight = getRemainingHeight( element, ( height - ( padding * 2 ) ) );
    
    			// Consider the aspect ratio of media elements
    			if( /(img|video)/gi.test( element.nodeName ) ) {
    
    				var nw = element.naturalWidth || element.videoWidth,
    					nh = element.naturalHeight || element.videoHeight;
    
    
    				var es = Math.min( width / nw, remainingHeight / nh );
    
    				element.style.width = ( nw * es ) + 'px';
    				element.style.height = ( nh * es ) + 'px';
    
    			}
    			else {
    				element.style.width = width + 'px';
    				element.style.height = remainingHeight + 'px';
    			}
    
    		} );
    
    	}
    
    
    	 * Stores the vertical index of a stack so that the same
    	 * vertical slide can be selected when navigating to and
    
    	 * @param {HTMLElement} stack The vertical stack element
    	 * @param {int} v Index to memorize
    	 */
    	function setPreviousVerticalIndex( stack, v ) {
    
    		if( typeof stack === 'object' && typeof stack.setAttribute === 'function' ) {
    
    			stack.setAttribute( 'data-previous-indexv', v || 0 );
    		}
    
    	 * Retrieves the vertical index which was stored using
    
    	 * #setPreviousVerticalIndex() or 0 if no previous index
    	 * exists.
    	 *
    	 * @param {HTMLElement} stack The vertical stack element
    	 */
    	function getPreviousVerticalIndex( stack ) {
    
    		if( typeof stack === 'object' && typeof stack.setAttribute === 'function' && stack.classList.contains( 'stack' ) ) {
    
    			// Prefer manually defined start-indexv
    			var attributeName = stack.hasAttribute( 'data-start-indexv' ) ? 'data-start-indexv' : 'data-previous-indexv';
    
    			return parseInt( stack.getAttribute( attributeName ) || 0, 10 );
    
    	 * Displays the overview of slides (quick nav) by
    
    	 * scaling down and arranging all slide elements.
    
    	 *
    	 * Experimental feature, might be dropped if perf
    
    	 * can't be improved.
    	 */
    	function activateOverview() {
    
    		// Only proceed if enabled in config
    
    		if( config.overview ) {
    
    			// Don't auto-slide while in overview mode
    			cancelAutoSlide();
    
    
    			var wasActive = dom.wrapper.classList.contains( 'overview' );
    
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    			// Vary the depth of the overview based on screen size
    			var depth = window.innerWidth < 400 ? 1000 : 2500;
    
    			dom.wrapper.classList.add( 'overview' );
    
    			dom.wrapper.classList.remove( 'overview-deactivating' );
    
    hakimel's avatar
    hakimel committed
    
    
    			clearTimeout( activateOverviewTimeout );
    
    Joel Brandt's avatar
    Joel Brandt committed
    			clearTimeout( deactivateOverviewTimeout );
    
    			// Not the pretties solution, but need to let the overview
    			// class apply first so that slides are measured accurately
    
    			activateOverviewTimeout = setTimeout( function() {
    
    
    				var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
    
    				for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
    					var hslide = horizontalSlides[i],
    
    						hoffset = config.rtl ? -105 : 105;
    
    
    					hslide.setAttribute( 'data-index-h', i );
    
    
    					// Apply CSS transform
    					transformElement( hslide, 'translateZ(-'+ depth +'px) translate(' + ( ( i - indexh ) * hoffset ) + '%, 0%)' );
    
    
    					if( hslide.classList.contains( 'stack' ) ) {
    
    						var verticalSlides = hslide.querySelectorAll( 'section' );
    
    						for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
    							var verticalIndex = i === indexh ? indexv : getPreviousVerticalIndex( hslide );
    
    
    							var vslide = verticalSlides[j];
    
    
    							vslide.setAttribute( 'data-index-h', i );
    							vslide.setAttribute( 'data-index-v', j );
    
    
    							// Apply CSS transform
    							transformElement( vslide, 'translate(0%, ' + ( ( j - verticalIndex ) * 105 ) + '%)' );
    
    
    							// Navigate to this slide on click
    							vslide.addEventListener( 'click', onOverviewSlideClicked, true );
    						}
    
    						hslide.addEventListener( 'click', onOverviewSlideClicked, true );
    
    
    				if( !wasActive ) {
    					// Notify observers of the overview showing
    					dispatchEvent( 'overviewshown', {
    						'indexh': indexh,
    						'indexv': indexv,
    						'currentSlide': currentSlide
    					} );
    				}
    
    
    	/**
    	 * Exits the slide overview and enters the currently
    	 * active slide.
    	 */
    
    	function deactivateOverview() {
    
    		// Only proceed if enabled in config
    
    		if( config.overview ) {
    
    			clearTimeout( activateOverviewTimeout );
    
    Joel Brandt's avatar
    Joel Brandt committed
    			clearTimeout( deactivateOverviewTimeout );
    
    			dom.wrapper.classList.remove( 'overview' );
    
    hakimel's avatar
    hakimel committed
    
    
    Joel Brandt's avatar
    Joel Brandt committed
    			// 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( 'overview-deactivating' );
    
    hakimel's avatar
    hakimel committed
    
    
    Joel Brandt's avatar
    Joel Brandt committed
    			deactivateOverviewTimeout = setTimeout( function () {
    
    				dom.wrapper.classList.remove( 'overview-deactivating' );
    			}, 1 );
    
    			toArray( document.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
    
    				// Resets all transforms to use the external styles
    
    				transformElement( slide, '' );
    
    				slide.removeEventListener( 'click', onOverviewSlideClicked, true );
    			} );
    
    			// Notify observers of the overview hiding
    			dispatchEvent( 'overviewhidden', {
    				'indexh': indexh,
    				'indexv': indexv,
    				'currentSlide': currentSlide
    			} );
    
    
    	 * @param {Boolean} override Optional flag which overrides the
    	 * toggle logic and forcibly sets the desired state. True means
    
    	 * overview is open, false means it's closed.
    	 */
    	function toggleOverview( override ) {
    
    		if( typeof override === 'boolean' ) {
    			override ? activateOverview() : deactivateOverview();
    		}
    		else {
    
    			isOverview() ? deactivateOverview() : activateOverview();
    
    	/**
    	 * Checks if the overview is currently active.
    
    	 * @return {Boolean} true if the overview is active,
    	 * false otherwise
    	 */
    
    		return dom.wrapper.classList.contains( 'overview' );
    
    	/**
    	 * Checks if the current or specified slide is vertical
    	 * (nested within another slide).
    	 *
    	 * @param {HTMLElement} slide [optional] The slide to check
    	 * orientation of
    	 */
    	function isVerticalSlide( slide ) {
    
    		// Prefer slide argument, otherwise use current slide
    		slide = slide ? slide : currentSlide;
    
    
    		return slide && slide.parentNode && !!slide.parentNode.nodeName.match( /section/i );
    
    	/**
    	 * Handling the fullscreen functionality via the fullscreen API
    
    	 *
    	 * @see http://fullscreen.spec.whatwg.org/
    	 * @see https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
    
    	 */
    	function enterFullscreen() {
    
    		var element = document.body;
    
    		// Check which implementation is available
    		var requestMethod = element.requestFullScreen ||
    
    							element.webkitRequestFullScreen ||
    							element.mozRequestFullScreen ||
    							element.msRequestFullScreen;
    
    		if( requestMethod ) {
    			requestMethod.apply( element );
    		}
    
    	 * Enters the paused mode which fades everything on screen to
    
    		var wasPaused = dom.wrapper.classList.contains( 'paused' );
    
    
    		if( wasPaused === false ) {
    			dispatchEvent( 'paused' );
    		}
    
    
    		var wasPaused = dom.wrapper.classList.contains( 'paused' );
    
    		dom.wrapper.classList.remove( 'paused' );
    
    		if( wasPaused ) {
    			dispatchEvent( 'resumed' );
    		}
    
    
    	}
    
    	/**
    	 * Toggles the paused mode on and off.
    	 */
    	function togglePause() {
    
    	}
    
    	/**
    	 * Checks if we are currently in the paused mode.
    	 */
    	function isPaused() {
    
    		return dom.wrapper.classList.contains( 'paused' );
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	/**
    
    	 * Steps from the current point in the presentation to the
    	 * slide which matches the specified horizontal and vertical
    	 * indices.
    
    	 *
    	 * @param {int} h Horizontal index of the target slide
    	 * @param {int} v Vertical index of the target slide
    
    	 * @param {int} f Optional index of a fragment within the
    
    	 * target slide to activate
    
    David Banham's avatar
    David Banham committed
    	 * @param {int} o Optional origin for use in multimaster environments
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	 */
    
    David Banham's avatar
    David Banham committed
    	function slide( h, v, f, o ) {
    
    		// Remember where we were at before
    		previousSlide = currentSlide;
    
    
    		// Query all horizontal slides in the deck
    		var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
    
    		// If no vertical index is specified and the upcoming slide is a
    
    		// stack, resume at its previous vertical index
    
    		if( v === undefined ) {
    			v = getPreviousVerticalIndex( horizontalSlides[ h ] );
    
    		// If we were on a vertical stack, remember what vertical index
    
    		// it was on so we can resume at the same position when returning
    
    		if( previousSlide && previousSlide.parentNode && previousSlide.parentNode.classList.contains( 'stack' ) ) {
    
    			setPreviousVerticalIndex( previousSlide.parentNode, indexv );
    
    		// Remember the state before this slide
    		var stateBefore = state.concat();
    
    		// Reset the state array
    		state.length = 0;
    
    		var indexhBefore = indexh || 0,
    			indexvBefore = indexv || 0;
    
    		// Activate and transition to the new slide
    
    		indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h );
    		indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v );
    
    		// Update the visibility of slides now that the indices have changed
    		updateSlidesVisibility();
    
    
    		stateLoop: for( var i = 0, len = state.length; i < len; i++ ) {
    
    			// Check if this state existed on the previous slide. If it
    
    			// did, we will avoid adding it repeatedly
    
    			for( var j = 0; j < stateBefore.length; j++ ) {
    				if( stateBefore[j] === state[i] ) {
    					stateBefore.splice( j, 1 );
    					continue stateLoop;
    				}
    			}
    
    
    			// Dispatch custom event matching the state's name
    			dispatchEvent( state[i] );
    
    		// Clean up the remains of the previous state
    
    		while( stateBefore.length ) {
    			document.documentElement.classList.remove( stateBefore.pop() );
    
    		// If the overview is active, re-activate it to update positions
    
    		// Find the current horizontal slide and any possible vertical slides
    		// within it
    		var currentHorizontalSlide = horizontalSlides[ indexh ],
    			currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
    
    		// Store references to the previous and current slides
    		currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
    
    		// Show fragment, if specified
    
    		if( typeof f !== 'undefined' ) {
    
    			navigateFragment( f );
    
    		// Dispatch an event if the slide changed
    
    		var slideChanged = ( indexh !== indexhBefore || indexv !== indexvBefore );
    
    				'indexh': indexh,
    
    David Banham's avatar
    David Banham committed
    				'currentSlide': currentSlide,
    				'origin': o
    
    		else {
    			// Ensure that the previous slide is never the same as the current
    			previousSlide = null;
    		}
    
    		// Solves an edge case where the previous slide maintains the
    		// 'present' class when navigating between adjacent vertical
    
    		// stacks
    		if( previousSlide ) {
    			previousSlide.classList.remove( 'present' );
    
    karimsa's avatar
    karimsa committed
    
    
    			// Reset all slides upon navigate to home
    			// Issue: #285
    			if ( document.querySelector( HOME_SLIDE_SELECTOR ).classList.contains( 'present' ) ) {
    				// Launch async task
    				setTimeout( function () {
    					var slides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.stack') ), i;
    					for( i in slides ) {
    						if( slides[i] ) {
    							// Reset stack
    							setPreviousVerticalIndex( slides[i], 0 );
    						}
    					}
    				}, 0 );
    			}
    
    		if( slideChanged ) {
    
    			stopEmbeddedContent( previousSlide );
    			startEmbeddedContent( currentSlide );
    		}
    
    		updateControls();
    		updateProgress();
    
    		updateParallax();
    
    		// Update the URL hash
    		writeURL();
    
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	}
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	/**
    	 * Syncs the presentation with the current DOM. Useful
    	 * when new slides or control elements are added or when
    	 * the configuration has changed.
    	 */
    	function sync() {
    
    		// Subscribe to input
    		removeEventListeners();
    		addEventListeners();
    
    		// Force a layout to make sure the current config is accounted for
    		layout();
    
    		// Reflect the current autoSlide value
    		autoSlide = config.autoSlide;
    
    		// Start auto-sliding if it's enabled
    		cueAutoSlide();
    
    
    		// Re-create the slide backgrounds
    		createBackgrounds();
    
    
    		updateControls();
    		updateProgress();
    
    		updateBackground( true );
    
    	/**
    	 * Iterates through and decorates slides DOM elements with
    	 * appropriate classes.
    	 */
    	function formatSlides() {
    
    		var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
    		horizontalSlides.forEach( function( horizontalSlide ) {
    
    			var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
    			verticalSlides.forEach( function( verticalSlide, y ) {
    
    				if( y > 0 ) verticalSlide.classList.add( 'future' );
    
    				sortFragments( verticalSlide.querySelectorAll( '.fragment' ) );
    
    			} );
    
    			if( verticalSlides.length === 0 ) sortFragments( horizontalSlide.querySelectorAll( '.fragment' ) );
    
    		} );
    
    	}
    
    
    	/**
    	 * Updates one dimension of slides by showing the slide
    	 * with the specified index.
    
    	 * @param {String} selector A CSS selector that will fetch
    	 * the group of slides we are working with
    	 * @param {Number} index The index of the slide that should be
    	 * shown
    
    	 * @return {Number} The index of the slide that is now shown,
    
    	 * might differ from the passed in index if it was out of
    
    	 * bounds.
    	 */
    	function updateSlides( selector, index ) {
    
    		// Select all slides and convert the NodeList result to
    		// an array
    
    		var slides = toArray( document.querySelectorAll( selector ) ),
    
    		if( slidesLength ) {
    
    			// Should the index loop?
    			if( config.loop ) {
    				index %= slidesLength;
    
    				if( index < 0 ) {
    					index = slidesLength + index;
    				}
    			}
    
    			// Enforce max and minimum index bounds
    			index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
    
    			for( var i = 0; i < slidesLength; i++ ) {
    				var element = slides[i];
    
    
    				var reverse = config.rtl && !isVerticalSlide( element );
    
    
    				element.classList.remove( 'past' );
    				element.classList.remove( 'present' );
    				element.classList.remove( 'future' );
    
    				// http://www.w3.org/html/wg/drafts/html/master/editing.html#the-hidden-attribute
    				element.setAttribute( 'hidden', '' );
    
    
    				if( i < index ) {
    					// Any element previous to index is given the 'past' class
    
    					element.classList.add( reverse ? 'future' : 'past' );
    
    
    					var pastFragments = toArray( element.querySelectorAll( '.fragment' ) );
    
    					// Show all fragments on prior slides
    					while( pastFragments.length ) {
    
    						var pastFragment = pastFragments.pop();
    						pastFragment.classList.add( 'visible' );
    						pastFragment.classList.remove( 'current-fragment' );
    
    				}
    				else if( i > index ) {
    					// Any element subsequent to index is given the 'future' class
    
    					element.classList.add( reverse ? 'past' : 'future' );
    
    					var futureFragments = toArray( element.querySelectorAll( '.fragment.visible' ) );
    
    
    					// No fragments in future slides should be visible ahead of time
    
    					while( futureFragments.length ) {
    
    						var futureFragment = futureFragments.pop();
    						futureFragment.classList.remove( 'visible' );
    						futureFragment.classList.remove( 'current-fragment' );
    
    				}
    
    				// If this element contains vertical slides
    				if( element.querySelector( 'section' ) ) {
    
    					element.classList.add( 'stack' );
    
    				}
    			}
    
    			// Mark the current slide as present
    			slides[index].classList.add( 'present' );
    
    			slides[index].removeAttribute( 'hidden' );
    
    
    			// If this slide has a state associated with it, add it
    			// onto the current state of the deck
    			var slideState = slides[index].getAttribute( 'data-state' );
    			if( slideState ) {
    				state = state.concat( slideState.split( ' ' ) );
    			}
    
    		}
    		else {
    
    			// Since there are no slides we can't be anywhere beyond the
    
    	/**
    	 * Optimization method; hide all slides that are far away
    	 * from the present slide.
    	 */
    	function updateSlidesVisibility() {
    
    		// Select all slides and convert the NodeList result to
    		// an array
    		var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ),
    			horizontalSlidesLength = horizontalSlides.length,
    
    
    		if( horizontalSlidesLength ) {
    
    			// The number of steps away from the present slide that will
    			// be visible
    
    			var viewDistance = isOverview() ? 10 : config.viewDistance;
    
    			// Limit view distance on weaker devices
    
    				viewDistance = isOverview() ? 6 : 1;
    
    			}
    
    			for( var x = 0; x < horizontalSlidesLength; x++ ) {
    				var horizontalSlide = horizontalSlides[x];
    
    				var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ),
    					verticalSlidesLength = verticalSlides.length;
    
    
    				// Loops so that it measures 1 between the first and last slides
    				distanceX = Math.abs( ( indexh - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
    
    
    				// Show the horizontal slide if it's within the view distance
    				horizontalSlide.style.display = distanceX > viewDistance ? 'none' : 'block';
    
    				if( verticalSlidesLength ) {
    
    					var oy = getPreviousVerticalIndex( horizontalSlide );
    
    
    					for( var y = 0; y < verticalSlidesLength; y++ ) {
    						var verticalSlide = verticalSlides[y];
    
    
    						distanceY = x === indexh ? Math.abs( indexv - y ) : Math.abs( y - oy );
    
    						verticalSlide.style.display = ( distanceX + distanceY ) > viewDistance ? 'none' : 'block';
    
    	 * Updates the progress bar to reflect the current slide.
    	 */
    	function updateProgress() {
    
    		// Update progress if enabled
    		if( config.progress && dom.progress ) {
    
    			var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
    
    			// The number of past and total slides
    			var totalCount = document.querySelectorAll( SLIDES_SELECTOR + ':not(.stack)' ).length;
    			var pastCount = 0;
    
    			// Step through all slides and count the past ones
    			mainLoop: for( var i = 0; i < horizontalSlides.length; i++ ) {
    
    				var horizontalSlide = horizontalSlides[i];
    				var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
    
    				for( var j = 0; j < verticalSlides.length; j++ ) {
    
    					// Stop as soon as we arrive at the present
    
    					if( verticalSlides[j].classList.contains( 'present' ) ) {
    						break mainLoop;
    					}
    
    
    				}
    
    				// Stop as soon as we arrive at the present
    
    				if( horizontalSlide.classList.contains( 'present' ) ) {
    					break;
    				}
    
    
    				// Don't count the wrapping section for vertical slides
    
    				if( horizontalSlide.classList.contains( 'stack' ) === false ) {
    					pastCount++;
    				}
    
    
    			}
    
    			dom.progressbar.style.width = ( pastCount / ( totalCount - 1 ) ) * window.innerWidth + 'px';
    
    		}
    
    	/**
    	 * Updates the slide number div to reflect the current slide.
    	 */
    	function updateSlideNumber() {
    
    		// Update slide number if enabled
    
    			// Display the number of the page using 'indexh - indexv' format
    
    				indexString += ' - ' + indexv;
    
    			dom.slideNumber.innerHTML = indexString;
    
    	/**
    	 * Updates the state of all control/navigation arrows.
    
    		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' ); } );
    
    		// 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 ) {
    
    			// 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' ); } );
    
    danielmitd's avatar
    danielmitd committed
    		}
    
    	 * Updates the background elements to reflect the current
    
    	 *
    	 * @param {Boolean} includeAll If true, the backgrounds of
    	 * all vertical slides (not just the present) will be updated.
    
    	function updateBackground( includeAll ) {
    
    		var currentBackground = null;
    
    		// Reverse past/future classes when in RTL mode
    		var horizontalPast = config.rtl ? 'future' : 'past',
    			horizontalFuture = config.rtl ? 'past' : 'future';
    
    
    		// Update the classes of all backgrounds to match the
    
    		// states of their slides (past/present/future)
    
    		toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
    
    
    				backgroundh.className = 'slide-background ' + horizontalPast;
    
    			}
    			else if ( h > indexh ) {
    
    				backgroundh.className = 'slide-background ' + horizontalFuture;
    
    				backgroundh.className = 'slide-background present';
    
    
    				// Store a reference to the current background element
    				currentBackground = backgroundh;
    			}
    
    			if( includeAll || h === indexh ) {
    				toArray( backgroundh.childNodes ).forEach( function( backgroundv, v ) {
    
    					if( v < indexv ) {
    						backgroundv.className = 'slide-background past';
    					}
    					else if ( v > indexv ) {
    						backgroundv.className = 'slide-background future';
    					}
    					else {
    						backgroundv.className = 'slide-background present';
    
    						// Only if this is the present horizontal and vertical slide
    						if( h === indexh ) currentBackground = backgroundv;
    					}
    
    		// Don't transition between identical backgrounds. This
    		// prevents unwanted flicker.
    		if( currentBackground ) {
    
    			var previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null;
    
    			var currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
    
    			if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== previousBackground ) {
    
    				dom.background.classList.add( 'no-transition' );
    			}
    
    
    			previousBackground = currentBackground;
    
    		// Allow the first background to apply without transition
    		setTimeout( function() {
    			dom.background.classList.remove( 'no-transition' );
    		}, 1 );
    
    
    	/**
    	 * Updates the position of the parallax background based
    	 * on the current slide index.
    	 */
    	function updateParallax() {
    
    
    		if( config.parallaxBackgroundImage ) {
    
    			var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
    				verticalSlides = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
    
    			var backgroundSize = dom.background.style.backgroundSize.split( ' ' ),
    
    				backgroundWidth, backgroundHeight;
    
    			if( backgroundSize.length === 1 ) {