greatly simplify next/prev fragment routines

This commit is contained in:
Hakim El Hattab 2013-04-27 16:23:28 -04:00
parent fdecb74cc8
commit 0ebda98735
2 changed files with 12 additions and 38 deletions

View file

@ -1498,27 +1498,14 @@ var Reveal = (function(){
*/ */
function nextFragment() { function nextFragment() {
// Vertical slides: if( currentSlide ) {
if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) { var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment:not(.visible)' ) );
var verticalFragments = sortFragments( document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' ) );
if( verticalFragments.length ) { if( fragments.length ) {
verticalFragments[0].classList.add( 'visible' ); fragments[0].classList.add( 'visible' );
// Notify subscribers of the change // Notify subscribers of the change
dispatchEvent( 'fragmentshown', { fragment: verticalFragments[0] } ); dispatchEvent( 'fragmentshown', { fragment: fragments[0] } );
return true;
}
}
// Horizontal slides:
else {
var horizontalFragments = sortFragments( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' ) );
if( horizontalFragments.length ) {
horizontalFragments[0].classList.add( 'visible' );
// Notify subscribers of the change
dispatchEvent( 'fragmentshown', { fragment: horizontalFragments[0] } );
return true; return true;
} }
} }
@ -1535,27 +1522,14 @@ var Reveal = (function(){
*/ */
function previousFragment() { function previousFragment() {
// Vertical slides: if( currentSlide ) {
if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) { var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) );
var verticalFragments = sortFragments( document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' ) );
if( verticalFragments.length ) { if( fragments.length ) {
verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' ); fragments[ fragments.length - 1 ].classList.remove( 'visible' );
// Notify subscribers of the change // Notify subscribers of the change
dispatchEvent( 'fragmenthidden', { fragment: verticalFragments[ verticalFragments.length - 1 ] } ); dispatchEvent( 'fragmenthidden', { fragment: fragments[ fragments.length - 1 ] } );
return true;
}
}
// Horizontal slides:
else {
var horizontalFragments = sortFragments( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' ) );
if( horizontalFragments.length ) {
horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' );
// Notify subscribers of the change
dispatchEvent( 'fragmenthidden', { fragment: horizontalFragments[ horizontalFragments.length - 1 ] } );
return true; return true;
} }
} }

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long