ensure that all fragments on past slides are visible #684

edit
Hakim El Hattab 2013-11-07 08:39:19 -05:00
parent e7e941b663
commit a119c83f86
3 changed files with 22 additions and 5 deletions

View File

@ -1699,16 +1699,23 @@ var Reveal = (function(){
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 ) {
pastFragments.pop().classList.add( 'visible' );
}
}
else if( i > index ) {
// Any element subsequent to index is given the 'future' class
element.classList.add( reverse ? 'past' : 'future' );
var fragments = toArray( element.querySelectorAll( '.fragment.visible' ) );
var futureFragments = toArray( element.querySelectorAll( '.fragment.visible' ) );
// No fragments in future slides should be visible ahead of time
while( fragments.length ) {
fragments.pop().classList.remove( 'visible' );
while( futureFragments.length ) {
futureFragments.pop().classList.remove( 'visible' );
}
}

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -204,6 +204,16 @@ Reveal.addEventListener( 'ready', function() {
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'left() goes to prev fragment' );
});
test( 'Stepping past fragments', function() {
var fragmentSlide = document.querySelector( '.reveal .slides>section:nth-child(3)' );
Reveal.slide( 0, 0, 0 );
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' );
Reveal.slide( 3, 0, 0 );
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 3, 'all fragments visible when on future slide' );
});
asyncTest( 'fragmentshown event', function() {
expect( 2 );