Procházet zdrojové kódy

Add a more flexible autoSlideMethod option

Auto-sliding will now use the method specified in the config if it is
a function or default to navigateNext.
MichiK před 9 roky
rodič
revize
4a45557b57
2 změnil soubory, kde provedl 9 přidání a 15 odebrání
  1. 4 4
      README.md
  2. 5 11
      js/reveal.js

+ 4 - 4
README.md

@@ -152,10 +152,8 @@ Reveal.initialize({
 	// Stop auto-sliding after user input
 	autoSlideStoppable: true,
 
-	// When auto-sliding is active, do always proceed to the right
-	// instead of the next slide which may be below (useful for
-	// infinite loop presentations with hidden "bonus slides")
-	autoSlideRight: false,
+	// Use this method for navigation when auto-sliding
+	autoSlideMethod: Reveal.navigateNext,
 
 	// Enable slide navigation via mouse wheel
 	mouseWheel: false,
@@ -302,6 +300,8 @@ You can also override the slide duration for individual slides and fragments by
 </section>
 ```
 
+To override the method used for navigation when auto-sliding, you can specify the ```autoSlideMethod``` setting. To only navigate along the top layer and ignore vertical slides, set this to ```Reveal.navigateRight```.
+
 Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired.
 
 

+ 5 - 11
js/reveal.js

@@ -103,11 +103,6 @@
 			// Stop auto-sliding after user input
 			autoSlideStoppable: true,
 
-			// When auto-sliding is active, do always proceed to the right
-			// instead of the next slide which may be below (useful for
-			// infinite loop presentations with hidden "bonus slides")
-			autoSlideRight: false,
-
 			// Enable slide navigation via mouse wheel
 			mouseWheel: false,
 
@@ -3693,7 +3688,10 @@
 			// - The overview isn't active
 			// - The presentation isn't over
 			if( autoSlide && !autoSlidePaused && !isPaused() && !isOverview() && ( !Reveal.isLastSlide() || availableFragments().next || config.loop === true ) ) {
-				autoSlideTimeout = setTimeout( navigateNext, autoSlide );
+				autoSlideTimeout = setTimeout( function() {
+					typeof config.autoSlideMethod == 'function' ? config.autoSlideMethod() : navigateNext();
+					cueAutoSlide();
+				}, autoSlide );
 				autoSlideStartTime = Date.now();
 			}
 
@@ -3828,7 +3826,7 @@
 
 		// Prioritize revealing fragments
 		if( nextFragment() === false ) {
-			if( availableRoutes().down && !( autoSlide && config.autoSlideRight ) ) {
+			if( availableRoutes().down ) {
 				navigateDown();
 			}
 			else if( config.rtl ) {
@@ -3839,10 +3837,6 @@
 			}
 		}
 
-		// If auto-sliding is enabled we need to cue up
-		// another timeout
-		cueAutoSlide();
-
 	}
 
 	/**