Selaa lähdekoodia

ensure that all fragments on past slides are visible #684

Hakim El Hattab 11 vuotta sitten
vanhempi
commit
a119c83f86
3 muutettua tiedostoa jossa 21 lisäystä ja 4 poistoa
  1. 10 3
      js/reveal.js
  2. 1 1
      js/reveal.min.js
  3. 10 0
      test/test.js

+ 10 - 3
js/reveal.js

@@ -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' );
 					}
 				}
 

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 1
js/reveal.min.js


+ 10 - 0
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' );
 	});
 
+	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 );
 

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä