From f6bae66089c71f0be8c9b9b2ec4091557af94e8d Mon Sep 17 00:00:00 2001 From: ageier Date: Thu, 11 Oct 2012 19:13:18 +0200 Subject: [PATCH] Make it possible to customize autoSlide for each slide --- README.md | 3 ++- js/reveal.js | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5b1684e..4a2797a 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,8 @@ Reveal.initialize({ loop: false, // Number of milliseconds between automatically proceeding to the - // next slide, disabled when set to 0 + // next slide, disabled when set to 0, this value can be overwritten + // by using a data-autoSlide attribute on your slides autoSlide: 0, // Enable slide navigation via mouse wheel diff --git a/js/reveal.js b/js/reveal.js index c9ba7b1..9293337 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -33,7 +33,8 @@ var Reveal = (function(){ loop: false, // Number of milliseconds between automatically proceeding to the - // next slide, disabled when set to 0 + // next slide, disabled when set to 0, this value can be overwritten + // by using a data-autoSlide attribute on your slides autoSlide: 0, // Enable slide navigation via mouse wheel @@ -52,6 +53,10 @@ var Reveal = (function(){ dependencies: [] }, + // stores if the next slide should be shown automatically + // after n milliseconds + autoSlide = config.autoSlide, + // The horizontal and verical index of the currently active slide indexh = 0, indexv = 0, @@ -100,7 +105,6 @@ var Reveal = (function(){ threshold: 40 }; - /** * Starts up the presentation if the client is capable. */ @@ -780,7 +784,6 @@ var Reveal = (function(){ * bounds. */ function updateSlides( selector, index ) { - // Select all slides and convert the NodeList result to // an array var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ), @@ -841,6 +844,16 @@ var Reveal = (function(){ if( slideState ) { state = state.concat( slideState.split( ' ' ) ); } + + // if this slide has a autoSlide attribtue associated use this as autoSlide value + // otherwise use the global configured time + var slideAutoSlide = slides[index].getAttribute( 'data-autoslide' ); + if( slideAutoSlide ) { + autoSlide = parseInt(slideAutoSlide); + } else { + autoSlide = config.autoSlide + } + } else { // Since there are no slides we can't be anywhere beyond the @@ -1111,8 +1124,8 @@ var Reveal = (function(){ clearTimeout( autoSlideTimeout ); // Cue the next auto-slide if enabled - if( config.autoSlide ) { - autoSlideTimeout = setTimeout( navigateNext, config.autoSlide ); + if( autoSlide ) { + autoSlideTimeout = setTimeout( navigateNext, autoSlide ); } }