Skip to content

Commit

Permalink
Introduce alternate pacing timer, based on total presentation time
Browse files Browse the repository at this point in the history
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.

In order to maintain backward compatibility, defaultTiming overrides
totalTime. That is to say, if both defaultTiming and totalTime are
set to nonzero, non-null values, defaultTiming wins and totalTime
is ignored. Only if defaultTiming is 0 or null, and totalTime is set,
the totalTime pacing calculation applies.
  • Loading branch information
fghaas committed May 9, 2019
1 parent a16b71a commit 9b5e04d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ Reveal.initialize({
// speaker view
defaultTiming: 120,

// Specify the total time in seconds that is available to present.
// If defaultTiming is not set and this is set to a nonzero valie,
// the pacing timer will instead work out the time available for
// each slide
totalTime: 0,

// Enable slide navigation via mouse wheel
mouseWheel: false,

Expand Down Expand Up @@ -1228,7 +1234,7 @@ The speaker notes window will also show:
- Current wall-clock time
- (Optionally) a pacing timer which indicates whether the current pace of the presentation is on track for the right timing (shown in green), and if not, whether the presenter should speed up (shown in red) or has the luxury of slowing down (blue).

The pacing timer can be enabled by configuring by the `defaultTiming` parameter in the `Reveal` configuration block, which specifies the number of seconds per slide. 120 can be a reasonable rule of thumb. Timings can also be given per slide `<section>` by setting the `data-timing` attribute. Both values are in numbers of seconds.
The pacing timer be enabled by configuring by the `defaultTiming` parameter in the `Reveal` configuration block, which specifies the number of seconds per slide. 120 can be a reasonable rule of thumb. Alternatively, you can enable the timer by setting `totalTime`, which sets the total length of your presentation (also in seconds). If both values are specified, `defaultTiming` wins and `totalTime` is ignored. Regardless of the baseline timing method, timings can also be given per slide `<section>` by setting the `data-timing` attribute (again, in seconds).


## Server Side Speaker Notes
Expand Down
19 changes: 16 additions & 3 deletions plugin/notes/notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,14 @@ <h4 class="label">Notes</h4>
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
callRevealApi( 'getConfig', [], function ( config ) {
var defaultTiming = config.defaultTiming;
if (defaultTiming == null) {
var totalTime = config.totalTime;
if ((defaultTiming == null) && (totalTime == null)) {
callback(null);
return;
}

if (!defaultTiming && totalTime) {
defaultTiming = 0;
}
var timings = [];
for ( var i in slideAttributes ) {
var slide = slideAttributes[ i ];
Expand All @@ -559,7 +562,17 @@ <h4 class="label">Notes</h4>
}
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 );
} );
} );
Expand Down

0 comments on commit 9b5e04d

Please sign in to comment.