Make it possible to customize autoSlide for each slide

This commit is contained in:
ageier 2012-10-11 19:13:18 +02:00
parent 4dad42496e
commit f6bae66089
2 changed files with 20 additions and 6 deletions

View File

@ -75,7 +75,8 @@ Reveal.initialize({
loop: false, loop: false,
// Number of milliseconds between automatically proceeding to the // 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, autoSlide: 0,
// Enable slide navigation via mouse wheel // Enable slide navigation via mouse wheel

View File

@ -33,7 +33,8 @@ var Reveal = (function(){
loop: false, loop: false,
// Number of milliseconds between automatically proceeding to the // 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, autoSlide: 0,
// Enable slide navigation via mouse wheel // Enable slide navigation via mouse wheel
@ -52,6 +53,10 @@ var Reveal = (function(){
dependencies: [] 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 // The horizontal and verical index of the currently active slide
indexh = 0, indexh = 0,
indexv = 0, indexv = 0,
@ -100,7 +105,6 @@ var Reveal = (function(){
threshold: 40 threshold: 40
}; };
/** /**
* Starts up the presentation if the client is capable. * Starts up the presentation if the client is capable.
*/ */
@ -780,7 +784,6 @@ var Reveal = (function(){
* bounds. * bounds.
*/ */
function updateSlides( selector, index ) { function updateSlides( selector, index ) {
// Select all slides and convert the NodeList result to // Select all slides and convert the NodeList result to
// an array // an array
var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ), var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ),
@ -841,6 +844,16 @@ var Reveal = (function(){
if( slideState ) { if( slideState ) {
state = state.concat( slideState.split( ' ' ) ); 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 { else {
// Since there are no slides we can't be anywhere beyond the // Since there are no slides we can't be anywhere beyond the
@ -1111,8 +1124,8 @@ var Reveal = (function(){
clearTimeout( autoSlideTimeout ); clearTimeout( autoSlideTimeout );
// Cue the next auto-slide if enabled // Cue the next auto-slide if enabled
if( config.autoSlide ) { if( autoSlide ) {
autoSlideTimeout = setTimeout( navigateNext, config.autoSlide ); autoSlideTimeout = setTimeout( navigateNext, autoSlide );
} }
} }