ensure that all fragments on past slides are visible #684
This commit is contained in:
parent
e7e941b663
commit
a119c83f86
13
js/reveal.js
13
js/reveal.js
@ -1699,16 +1699,23 @@ var Reveal = (function(){
|
|||||||
if( i < index ) {
|
if( i < index ) {
|
||||||
// Any element previous to index is given the 'past' class
|
// Any element previous to index is given the 'past' class
|
||||||
element.classList.add( reverse ? 'future' : 'past' );
|
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 ) {
|
else if( i > index ) {
|
||||||
// Any element subsequent to index is given the 'future' class
|
// Any element subsequent to index is given the 'future' class
|
||||||
element.classList.add( reverse ? 'past' : 'future' );
|
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
|
// No fragments in future slides should be visible ahead of time
|
||||||
while( fragments.length ) {
|
while( futureFragments.length ) {
|
||||||
fragments.pop().classList.remove( 'visible' );
|
futureFragments.pop().classList.remove( 'visible' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
js/reveal.min.js
vendored
4
js/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
10
test/test.js
10
test/test.js
@ -204,6 +204,16 @@ Reveal.addEventListener( 'ready', function() {
|
|||||||
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'left() goes to prev fragment' );
|
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() {
|
asyncTest( 'fragmentshown event', function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user