Notes: Introduce alternate pacing timer, based on total presentation time
The current pacing timer operates on the assumption that there is a default amount of time to be allocated to each slide, and that individual slides can deviate from that default by specifying their own data-timing attribute. This patch introduces an alternate pacing method: by specifying the totalTime configuration option, the presenter can set the total time available to present. The pacing timer will then continue to allocate the exact pacing time for slides that do have data-timing set, as before. However, rather than applying the defaultTiming constant to all others, it will - Add up the time already allocated to slides via data-timing; - subtract that from totalTime; - divide the difference by the number of slides without data-timing set; - apply the thus-calculated average to those slides. totalTime has no default, and if both defaultTiming and totalTime are set, totalTime wins. This preserves backward compatibility: if a presenter has set defaultTiming and updates reveal.js, totalTime will be null and defaultTiming is still applied to all slides without a data-timing attribute. The presenter can then switch to the automatic calculation, if desired, by setting a value for totalTime.
This commit is contained in:
parent
a16b71a981
commit
078ba62050
|
@ -539,12 +539,16 @@
|
||||||
|
|
||||||
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
|
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
|
||||||
callRevealApi( 'getConfig', [], function ( config ) {
|
callRevealApi( 'getConfig', [], function ( config ) {
|
||||||
|
var totalTime = config.totalTime;
|
||||||
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 +563,17 @@
|
||||||
}
|
}
|
||||||
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) } );
|
||||||
|
}
|
||||||
callback( timings );
|
callback( timings );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user