aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2020-08-17 14:42:27 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2020-08-17 14:42:27 +0200
commit3a99a7b70aa7e74012c7049655da09959ca8c584 (patch)
treef9da0f98f61cf3fadab850f6f1de47e793cbbb5e /js
parent2bfe705e6ac8307c22d78a80bf237461658866ed (diff)
downloadfosdem-2021-minimalism-presentation-3a99a7b70aa7e74012c7049655da09959ca8c584.tar
fosdem-2021-minimalism-presentation-3a99a7b70aa7e74012c7049655da09959ca8c584.tar.gz
shuffle now applies to vertical slides as well
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 4657707..d5b3f79 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -1467,13 +1467,23 @@ export default function( revealElement, options ) {
/**
* Randomly shuffles all slides in the deck.
*/
- function shuffle() {
+ function shuffle( slides = getHorizontalSlides() ) {
- getHorizontalSlides().forEach( ( slide, i, slides ) => {
+ slides.forEach( ( slide, i ) => {
- // Insert this slide next to another random slide. This may
- // cause the slide to insert before itself but that's fine.
- dom.slides.insertBefore( slide, slides[ Math.floor( Math.random() * slides.length ) ] );
+ // Insert the slide next to a randomly picked sibling slide
+ // slide. This may cause the slide to insert before itself,
+ // but that's not an issue.
+ let beforeSlide = slides[ Math.floor( Math.random() * slides.length ) ];
+ if( beforeSlide.parentNode === slide.parentNode ) {
+ slide.parentNode.insertBefore( slide, beforeSlide );
+ }
+
+ // Randomize the order of vertical slides (if there are any)
+ let verticalSlides = slide.querySelectorAll( 'section' );
+ if( verticalSlides.length ) {
+ shuffle( verticalSlides );
+ }
} );