fragment comments, remove debug code

This commit is contained in:
Hakim El Hattab 2013-11-18 09:14:01 -05:00
parent 8550186afc
commit 9d0ac52780
2 changed files with 16 additions and 9 deletions

View File

@ -2272,8 +2272,13 @@ var Reveal = (function(){
/** /**
* Navigate to the specified slide fragment. * Navigate to the specified slide fragment.
* *
* @return {Boolean} true if there was a next fragment, * @param {Number} index The index of the fragment that
* false otherwise * should be shown, 1-based, 0 means all are invisible
* @param {Number} offset Integer offset to apply to the
* fragment index
*
* @return {Boolean} true if a change was made in any
* fragments visibility as part of this call
*/ */
function navigateFragment( index, offset ) { function navigateFragment( index, offset ) {
@ -2282,6 +2287,7 @@ var Reveal = (function(){
var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment' ) ); var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment' ) );
if( fragments.length ) { if( fragments.length ) {
// If no index is specified, find the current
if( typeof index !== 'number' ) { if( typeof index !== 'number' ) {
var lastVisibleFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop(); var lastVisibleFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
@ -2293,6 +2299,7 @@ var Reveal = (function(){
} }
} }
// If an offset is specified, apply it to the index
if( typeof offset === 'number' ) { if( typeof offset === 'number' ) {
index += offset; index += offset;
} }
@ -2302,6 +2309,7 @@ var Reveal = (function(){
toArray( fragments ).forEach( function( element, i ) { toArray( fragments ).forEach( function( element, i ) {
// Visible fragments
if( i < index ) { if( i < index ) {
if( !element.classList.contains( 'visible' ) ) fragmentsShown.push( element ); if( !element.classList.contains( 'visible' ) ) fragmentsShown.push( element );
element.classList.add( 'visible' ); element.classList.add( 'visible' );
@ -2311,6 +2319,7 @@ var Reveal = (function(){
element.classList.add( 'current-fragment' ); element.classList.add( 'current-fragment' );
} }
} }
// Hidden fragments
else { else {
if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element ); if( element.classList.contains( 'visible' ) ) fragmentsHidden.push( element );
element.classList.remove( 'visible' ); element.classList.remove( 'visible' );
@ -2320,13 +2329,11 @@ var Reveal = (function(){
} ); } );
if( offset < 0 && fragmentsHidden.length ) { if( fragmentsHidden.length ) {
console.log('hidden');
dispatchEvent( 'fragmenthidden', { fragment: fragmentsHidden[0], fragments: fragmentsHidden } ); dispatchEvent( 'fragmenthidden', { fragment: fragmentsHidden[0], fragments: fragmentsHidden } );
} }
if( offset > 0 && fragmentsShown.length ) { if( fragmentsShown.length ) {
console.log('shown');
dispatchEvent( 'fragmentshown', { fragment: fragmentsShown[0], fragments: fragmentsShown } ); dispatchEvent( 'fragmentshown', { fragment: fragmentsShown[0], fragments: fragmentsShown } );
} }

6
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long