Merge branch 'alternate-timing' of https://github.com/fghaas/reveal.js into dev
This commit is contained in:
commit
25e521a16c
|
@ -539,12 +539,17 @@
|
||||||
|
|
||||||
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
|
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
|
||||||
callRevealApi( 'getConfig', [], function ( config ) {
|
callRevealApi( 'getConfig', [], function ( config ) {
|
||||||
|
var totalTime = config.totalTime;
|
||||||
|
var minTimePerSlide = config.minimumTimePerSlide || 0;
|
||||||
var defaultTiming = config.defaultTiming;
|
var defaultTiming = config.defaultTiming;
|
||||||
if (defaultTiming == null) {
|
if ((defaultTiming == null) && (totalTime == null)) {
|
||||||
callback(null);
|
callback(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Setting totalTime overrides defaultTiming
|
||||||
|
if (totalTime) {
|
||||||
|
defaultTiming = 0;
|
||||||
|
}
|
||||||
var timings = [];
|
var timings = [];
|
||||||
for ( var i in slideAttributes ) {
|
for ( var i in slideAttributes ) {
|
||||||
var slide = slideAttributes[ i ];
|
var slide = slideAttributes[ i ];
|
||||||
|
@ -559,7 +564,22 @@
|
||||||
}
|
}
|
||||||
timings.push(timing);
|
timings.push(timing);
|
||||||
}
|
}
|
||||||
|
if ( totalTime ) {
|
||||||
|
// After we've allocated time to individual slides, we summarize it and
|
||||||
|
// subtract it from the total time
|
||||||
|
var remainingTime = totalTime - timings.reduce( function(a, b) { return a + b; }, 0 );
|
||||||
|
// The remaining time is divided by the number of slides that have 0 seconds
|
||||||
|
// allocated at the moment, giving the average time-per-slide on the remaining slides
|
||||||
|
var remainingSlides = (timings.filter( function(x) { return x == 0 }) ).length
|
||||||
|
var timePerSlide = Math.round( remainingTime / remainingSlides, 0 )
|
||||||
|
// And now we replace every zero-value timing with that average
|
||||||
|
timings = timings.map( function(x) { return (x==0 ? timePerSlide : x) } );
|
||||||
|
}
|
||||||
|
var slidesUnderMinimum = timings.filter( function(x) { return (x < minTimePerSlide) } ).length
|
||||||
|
if ( slidesUnderMinimum ) {
|
||||||
|
message = "The pacing time for " + slidesUnderMinimum + " slide(s) is under the configured minimum of " + minTimePerSlide + " seconds. Check the data-timing attribute on individual slides, or consider increasing the totalTime or minimumTimePerSlide configuration options (or removing some slides).";
|
||||||
|
alert(message);
|
||||||
|
}
|
||||||
callback( timings );
|
callback( timings );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user