aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2019-05-27 08:08:00 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2019-05-27 08:08:00 +0200
commit25e521a16cd1a35230fcd68cc74db423f2737ebb (patch)
treeaac959ae7b3fb0348be49943deced3cd8403f1a2 /plugin
parenta1dd1028a1dc433ae9bb35d36452e12d4d5279d8 (diff)
parent23c12d73321469743424264d9625eab72d8eb179 (diff)
downloadfosdem-2021-minimalism-presentation-25e521a16cd1a35230fcd68cc74db423f2737ebb.tar
fosdem-2021-minimalism-presentation-25e521a16cd1a35230fcd68cc74db423f2737ebb.tar.gz
Merge branch 'alternate-timing' of https://github.com/fghaas/reveal.js into dev
Diffstat (limited to 'plugin')
-rw-r--r--plugin/notes/notes.html26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html
index 9e0b230..fdb81ad 100644
--- a/plugin/notes/notes.html
+++ b/plugin/notes/notes.html
@@ -539,12 +539,17 @@
callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
callRevealApi( 'getConfig', [], function ( config ) {
+ var totalTime = config.totalTime;
+ var minTimePerSlide = config.minimumTimePerSlide || 0;
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 +564,22 @@
}
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 );
} );
} );