remove current-fragment when leaving slide, add tests for current fragment
This commit is contained in:
parent
ead723bc1c
commit
ef82645589
@ -1712,7 +1712,9 @@ var Reveal = (function(){
|
||||
|
||||
// Show all fragments on prior slides
|
||||
while( pastFragments.length ) {
|
||||
pastFragments.pop().classList.add( 'visible' );
|
||||
var pastFragment = pastFragments.pop();
|
||||
pastFragment.classList.add( 'visible' );
|
||||
pastFragment.classList.remove( 'current-fragment' );
|
||||
}
|
||||
}
|
||||
else if( i > index ) {
|
||||
@ -1723,7 +1725,9 @@ var Reveal = (function(){
|
||||
|
||||
// No fragments in future slides should be visible ahead of time
|
||||
while( futureFragments.length ) {
|
||||
futureFragments.pop().classList.remove( 'visible' );
|
||||
var futureFragment = futureFragments.pop();
|
||||
futureFragment.classList.remove( 'visible' );
|
||||
futureFragment.classList.remove( 'current-fragment' );
|
||||
}
|
||||
}
|
||||
|
||||
|
6
js/reveal.min.js
vendored
6
js/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
29
test/test.js
29
test/test.js
@ -166,6 +166,9 @@ Reveal.addEventListener( 'ready', function() {
|
||||
QUnit.module( 'Fragments' );
|
||||
|
||||
test( 'Sliding to fragments', function() {
|
||||
Reveal.slide( 2, 0, -1 );
|
||||
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'Reveal.slide( 2, 0, -1 )' );
|
||||
|
||||
Reveal.slide( 2, 0, 0 );
|
||||
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'Reveal.slide( 2, 0, 0 )' );
|
||||
|
||||
@ -176,6 +179,32 @@ Reveal.addEventListener( 'ready', function() {
|
||||
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'Reveal.slide( 2, 0, 1 )' );
|
||||
});
|
||||
|
||||
test( 'Hiding all fragments', function() {
|
||||
var fragmentSlide = document.querySelector( '.reveal .slides>section:nth-child(3)' );
|
||||
|
||||
Reveal.slide( 2, 0, 0 );
|
||||
strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 1, 'one fragment visible when index is 0' );
|
||||
|
||||
Reveal.slide( 2, 0, -1 );
|
||||
strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index 0' );
|
||||
});
|
||||
|
||||
test( 'Current fragment', function() {
|
||||
var fragmentSlide = document.querySelector( '.reveal .slides>section:nth-child(3)' );
|
||||
|
||||
Reveal.slide( 2, 0 );
|
||||
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment at index -1' );
|
||||
|
||||
Reveal.slide( 2, 0, 0 );
|
||||
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 1, 'one current fragment at index 0' );
|
||||
|
||||
Reveal.slide( 1, 0, 0 );
|
||||
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to previous slide' );
|
||||
|
||||
Reveal.slide( 3, 0, 0 );
|
||||
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to next slide' );
|
||||
});
|
||||
|
||||
test( 'Stepping through fragments', function() {
|
||||
Reveal.slide( 2, 0, -1 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user