|
@@ -539,12 +539,16 @@
|
|
|
|
|
|
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
|
|
|
callRevealApi( 'getConfig', [], function ( config ) {
|
|
|
+ var totalTime = config.totalTime;
|
|
|
var defaultTiming = config.defaultTiming;
|
|
|
- if (defaultTiming == null) {
|
|
|
+ if ((defaultTiming == null) && (totalTime == null)) {
|
|
|
callback(null);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ // Setting totalTime overrides defaultTiming
|
|
|
+ if (totalTime) {
|
|
|
+ defaultTiming = 0;
|
|
|
+ }
|
|
|
var timings = [];
|
|
|
for ( var i in slideAttributes ) {
|
|
|
var slide = slideAttributes[ i ];
|
|
@@ -559,7 +563,17 @@
|
|
|
}
|
|
|
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) } );
|
|
|
+ }
|
|
|
callback( timings );
|
|
|
} );
|
|
|
} );
|