shuffle now applies to vertical slides as well
This commit is contained in:
parent
2bfe705e6a
commit
3a99a7b70a
2
dist/reveal.esm.js
vendored
2
dist/reveal.esm.js
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.js
vendored
2
dist/reveal.js
vendored
File diff suppressed because one or more lines are too long
|
@ -16,8 +16,9 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="reveal">
|
<div class="reveal">
|
||||||
<div class="slides">
|
<div class="slides">
|
||||||
<section>Slide 1</section>
|
<section><section>Slide 1</section>
|
||||||
<section>Slide 2</section>
|
<section>Slide 2</section>
|
||||||
|
<section>Slide 3</section></section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
20
js/reveal.js
20
js/reveal.js
|
@ -1467,13 +1467,23 @@ export default function( revealElement, options ) {
|
||||||
/**
|
/**
|
||||||
* Randomly shuffles all slides in the deck.
|
* 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
|
// Insert the slide next to a randomly picked sibling slide
|
||||||
// cause the slide to insert before itself but that's fine.
|
// slide. This may cause the slide to insert before itself,
|
||||||
dom.slides.insertBefore( slide, slides[ Math.floor( Math.random() * slides.length ) ] );
|
// 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 );
|
||||||
|
}
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user