Sfoglia il codice sorgente

simplify how data-autoslide is picked up from fragments #766

Hakim El Hattab 11 anni fa
parent
commit
a97d73167d
3 ha cambiato i file con 8 aggiunte e 8 eliminazioni
  1. 3 7
      js/reveal.js
  2. 1 1
      js/reveal.min.js
  3. 4 0
      test/test.js

+ 3 - 7
js/reveal.js

@@ -1456,6 +1456,7 @@ var Reveal = (function(){
 	 */
 
 	function toggleAutoSlide( override ) {
+
 		if( typeof override === 'boolean' ) {
 			override ? resumeAutoSlide() : pauseAutoSlide();
 		}
@@ -2500,14 +2501,9 @@ var Reveal = (function(){
 
 		if( currentSlide ) {
 
-			var fragmentAutoSlide = null;
-			// it is assumed that any given data-autoslide value (for each of the current fragments) can be chosen
-			toArray( Reveal.getCurrentSlide().querySelectorAll( '.current-fragment' ) ).forEach( function( el ) {
-				if( el.hasAttribute( 'data-autoslide' ) ) {
-					fragmentAutoSlide = el.getAttribute( 'data-autoslide' );
-				}
-			} );
+			var currentFragment = currentSlide.querySelector( '.current-fragment' );
 
+			var fragmentAutoSlide = currentFragment ? currentFragment.getAttribute( 'data-autoslide' ) : null;
 			var parentAutoSlide = currentSlide.parentNode ? currentSlide.parentNode.getAttribute( 'data-autoslide' ) : null;
 			var slideAutoSlide = currentSlide.getAttribute( 'data-autoslide' );
 

File diff suppressed because it is too large
+ 1 - 1
js/reveal.min.js


+ 4 - 0
test/test.js

@@ -63,6 +63,10 @@ Reveal.addEventListener( 'ready', function() {
 		Reveal.configure({ autoSlide: 10000 });
 		strictEqual( Reveal.isAutoSliding(), true, 'true after starting' );
 
+		Reveal.toggleAutoSlide();
+		strictEqual( Reveal.isAutoSliding(), false, 'false after toggling' );
+		Reveal.toggleAutoSlide();
+
 		Reveal.configure({ autoSlide: 0 });
 		strictEqual( Reveal.isAutoSliding(), false, 'false after setting to 0' );
 	});

Some files were not shown because too many files changed in this diff