added autoSlide option (#59), clear out list of options in index.html's initialize...
authorHakim El Hattab <hakim.elhattab@gmail.com>
Sun, 15 Jul 2012 23:21:47 +0000 (19:21 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Sun, 15 Jul 2012 23:21:47 +0000 (19:21 -0400)
README.md
index.html
js/reveal.js

index 602d81ce87fbb1cf07712597a2c6998e3ebd65d7..3f953627d871c83e59e4b89aa4da392335deeabe 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Markup heirarchy needs to be ``<div id="reveal"> <div class="slides"> <section>`
 
 ### Configuration
 
-At the end of your page, after ``<script src="js/reveal.js"></script>``, you need to initialize reveal by running the following code. Note that all config values are optional.
+At the end of your page, after ``<script src="js/reveal.js"></script>``, you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below.
 
 ```javascript
 Reveal.initialize({
@@ -36,13 +36,17 @@ Reveal.initialize({
        // Display a presentation progress bar
        progress: true,
 
-       // If true; each slide will be pushed to the browser history
-       history: true,
+       // Push each slide change to the browser history
+       history: false,
 
-       // Loops the presentation, defaults to false
+       // Loop the presentation
        loop: false,
 
-       // Flags if mouse wheel navigation should be enabled
+       // Number of milliseconds between automatically proceeding to the 
+       // next slide, disabled when set to 0
+       autoSlide: 0,
+
+       // Enable slide navigation via mouse wheel
        mouseWheel: true,
 
        // Apply a 3D roll to links on hover
@@ -170,6 +174,7 @@ You can change the appearance of the speaker notes by editing the file at `plugi
 - Slide notes by [rmurphey](https://github.com/rmurphey)
 - Bumped up default font-size for code samples
 - Added beige theme
+- Added 'autoSlide' config
 
 #### 1.3
 - Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff)
index 7f05d120de22e24ce95dbb7352f9221557731626..d67c17919d2968bd1ee95dfe868dfd7bd8f45498 100644 (file)
@@ -279,29 +279,14 @@ function linkify( selector ) {
                                        // event.previousSlide, event.currentSlide, event.indexh, event.indexv
                                } );
 
+                               // Full list of configuration options available here:
+                               // https://github.com/hakimel/reveal.js#configuration
                                Reveal.initialize({
-                                       // Display controls in the bottom right corner
                                        controls: true,
-
-                                       // Display a presentation progress bar
                                        progress: true,
-
-                                       // If true; each slide will be pushed to the browser history
                                        history: true,
 
-                                       // Loops the presentation, defaults to false
-                                       loop: false,
-
-                                       // Flags if mouse wheel navigation should be enabled
-                                       mouseWheel: true,
-
-                                       // Apply a 3D roll to links on hover
-                                       rollingLinks: true,
-
-                                       // UI style
                                        theme: query.theme || 'default', // default/neon/beige
-
-                                       // Transition style
                                        transition: query.transition || 'default' // default/cube/page/concave/linear(2d)
                                });
                        } );
index 856b1aa19b44798d69e8a64b978761f1a9806c9e..9276da3a6a138c155ded65ab67e2757571c7806a 100644 (file)
@@ -16,16 +16,35 @@ var Reveal = (function(){
                indexh = 0,
                indexv = 0,
 
-               // Configurations options, can be overridden at initialization time 
+               // Configurations defaults, can be overridden at initialization time 
                config = {
+                       // Display controls in the bottom right corner
                        controls: true,
-                       progress: false,
+
+                       // Display a presentation progress bar
+                       progress: true,
+
+                       // Push each slide change to the browser history
                        history: false,
+
+                       // Loop the presentation
                        loop: false,
+
+                       // Number of milliseconds between automatically proceeding to the 
+                       // next slide, disabled when set to 0
+                       autoSlide: 0,
+
+                       // Enable slide navigation via mouse wheel
                        mouseWheel: true,
+
+                       // Apply a 3D roll to links on hover
                        rollingLinks: true,
-                       transition: 'default',
-                       theme: 'default'
+
+                       // UI style
+                       theme: 'default', // default/neon/beige
+
+                       // Transition style
+                       transition: 'default' // default/cube/page/concave/linear(2d)
                },
 
                // Slides may hold a data-state attribute which we pick up and apply 
@@ -55,6 +74,9 @@ var Reveal = (function(){
                // Throttles mouse wheel navigation
                mouseWheelTimeout = 0,
 
+               // An interval used to automatically move on to the next slide
+               autoSlideTimeout = 0,
+
                // Delays updates to the URL due to a Chrome thumbnailer bug
                writeURLTimeout = 0,
 
@@ -107,6 +129,9 @@ var Reveal = (function(){
                // Read the initial hash
                readURL();
 
+               // Start auto-sliding if it's enabled
+               cueAutoSlide();
+
                // Set up hiding of the browser address bar
                if( navigator.userAgent.match( /(iphone|ipod|android)/i ) ) {
                        // Give the page some scrollable overflow
@@ -121,8 +146,8 @@ var Reveal = (function(){
        }
 
        function configure() {
-               // Fall back on the 2D transform theme 'linear'
                if( supports3DTransforms === false ) {
+                       // Fall back on the 2D transform theme 'linear'
                        config.transition = 'linear';
                }
 
@@ -269,20 +294,21 @@ var Reveal = (function(){
                        case 13: if( overviewIsActive() ) { deactivateOverview(); triggered = true; } break;
                }
 
+               // If the input resulted in a triggered action we should prevent 
+               // the browsers default behavior
                if( triggered ) {
                        event.preventDefault();
                }
                else if ( event.keyCode === 27 && supports3DTransforms ) {
-                       if( overviewIsActive() ) {
-                               deactivateOverview();
-                       }
-                       else {
-                               activateOverview();
-                       }
+                       toggleOverview();
        
                        event.preventDefault();
                }
 
+               // If auto-sliding is enabled we need to cue up 
+               // another timeout
+               cueAutoSlide();
+
        }
 
        /**
@@ -840,6 +866,15 @@ var Reveal = (function(){
                
                return false;
        }
+
+       function cueAutoSlide() {
+               clearTimeout( autoSlideTimeout );
+
+               // Cue the next auto-slide if enabled
+               if( config.autoSlide ) {
+                       autoSlideTimeout = setTimeout( navigateNext, config.autoSlide );
+               }
+       }
        
        /**
         * Triggers a navigation to the specified indices.
@@ -909,6 +944,10 @@ var Reveal = (function(){
                if( nextFragment() === false ) {
                        availableRoutes().down ? navigateDown() : navigateRight();
                }
+
+               // If auto-sliding is enabled we need to cue up 
+               // another timeout
+               cueAutoSlide();
        }
 
        /**