diff options
author | Hakim El Hattab | 2013-04-27 16:23:28 -0400 |
---|---|---|
committer | Hakim El Hattab | 2013-04-27 16:23:28 -0400 |
commit | 0ebda98735f0698e115a1ef1de495e67d8f65fd6 (patch) | |
tree | 67b0ae7cbcafeb0f24e9a3075abd59d16d502bcb /js/reveal.js | |
parent | fdecb74cc82d0f12df136c5269f4e8d466653d31 (diff) |
greatly simplify next/prev fragment routines
Diffstat (limited to 'js/reveal.js')
-rw-r--r-- | js/reveal.js | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/js/reveal.js b/js/reveal.js index 2a217c8..eea243e 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1498,27 +1498,14 @@ var Reveal = (function(){ */ function nextFragment() { - // Vertical slides: - if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) { - var verticalFragments = sortFragments( document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' ) ); + if( currentSlide ) { + var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment:not(.visible)' ) ); - if( verticalFragments.length ) { - verticalFragments[0].classList.add( 'visible' ); + if( fragments.length ) { + fragments[0].classList.add( 'visible' ); // Notify subscribers of the change - dispatchEvent( 'fragmentshown', { fragment: verticalFragments[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] } ); + dispatchEvent( 'fragmentshown', { fragment: fragments[0] } ); return true; } } @@ -1535,27 +1522,14 @@ var Reveal = (function(){ */ function previousFragment() { - // Vertical slides: - if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) { - var verticalFragments = sortFragments( document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' ) ); - - if( verticalFragments.length ) { - verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' ); - - // Notify subscribers of the change - dispatchEvent( 'fragmenthidden', { fragment: verticalFragments[ verticalFragments.length - 1 ] } ); - return true; - } - } - // Horizontal slides: - else { - var horizontalFragments = sortFragments( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' ) ); + if( currentSlide ) { + var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ); - if( horizontalFragments.length ) { - horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' ); + if( fragments.length ) { + fragments[ fragments.length - 1 ].classList.remove( 'visible' ); // Notify subscribers of the change - dispatchEvent( 'fragmenthidden', { fragment: horizontalFragments[ horizontalFragments.length - 1 ] } ); + dispatchEvent( 'fragmenthidden', { fragment: fragments[ fragments.length - 1 ] } ); return true; } } |