added support for looped presentations
This commit is contained in:
parent
eee6e5f964
commit
cde5362db3
|
@ -58,6 +58,9 @@ Reveal.initialize({
|
||||||
// If true; each slide will be pushed to the browser history
|
// If true; each slide will be pushed to the browser history
|
||||||
history: true,
|
history: true,
|
||||||
|
|
||||||
|
// Loops the presentation, defaults to false
|
||||||
|
loop: false,
|
||||||
|
|
||||||
// Flags if mouse wheel navigation should be enabled
|
// Flags if mouse wheel navigation should be enabled
|
||||||
mouseWheel: true,
|
mouseWheel: true,
|
||||||
|
|
||||||
|
@ -98,6 +101,7 @@ document.addEventListener( 'someState', function() {
|
||||||
|
|
||||||
#### 1.3 (master)
|
#### 1.3 (master)
|
||||||
- Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff)
|
- Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff)
|
||||||
|
- Added support for looped presentations via config
|
||||||
|
|
||||||
#### 1.2
|
#### 1.2
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,9 @@
|
||||||
// If true; each slide will be pushed to the browser history
|
// If true; each slide will be pushed to the browser history
|
||||||
history: true,
|
history: true,
|
||||||
|
|
||||||
|
// Loops the presentation, defaults to false
|
||||||
|
loop: false,
|
||||||
|
|
||||||
// Flags if mouse wheel navigation should be enabled
|
// Flags if mouse wheel navigation should be enabled
|
||||||
mouseWheel: true,
|
mouseWheel: true,
|
||||||
|
|
||||||
|
|
32
js/reveal.js
32
js/reveal.js
|
@ -19,10 +19,11 @@ var Reveal = (function(){
|
||||||
controls: false,
|
controls: false,
|
||||||
progress: false,
|
progress: false,
|
||||||
history: false,
|
history: false,
|
||||||
transition: 'default',
|
loop: false,
|
||||||
theme: 'default',
|
|
||||||
mouseWheel: true,
|
mouseWheel: true,
|
||||||
rollingLinks: true
|
rollingLinks: true,
|
||||||
|
transition: 'default',
|
||||||
|
theme: 'default'
|
||||||
},
|
},
|
||||||
|
|
||||||
// Slides may hold a data-state attribute which we pick up and apply
|
// Slides may hold a data-state attribute which we pick up and apply
|
||||||
|
@ -406,19 +407,34 @@ var Reveal = (function(){
|
||||||
|
|
||||||
// Select all slides and convert the NodeList result to
|
// Select all slides and convert the NodeList result to
|
||||||
// an array
|
// an array
|
||||||
var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) );
|
var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ),
|
||||||
|
slidesLength = slides.length;
|
||||||
|
|
||||||
|
if( slidesLength ) {
|
||||||
|
|
||||||
|
// Should the index loop?
|
||||||
|
if( config.loop ) {
|
||||||
|
index %= slidesLength;
|
||||||
|
|
||||||
|
if( index < 0 ) {
|
||||||
|
index = slidesLength + index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( slides.length ) {
|
|
||||||
// Enforce max and minimum index bounds
|
// Enforce max and minimum index bounds
|
||||||
index = Math.max(Math.min(index, slides.length - 1), 0);
|
index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
|
||||||
|
|
||||||
for( var i = 0; i < slides.length; i++ ) {
|
for( var i = 0; i < slidesLength; i++ ) {
|
||||||
var slide = slides[i];
|
var slide = slides[i];
|
||||||
|
|
||||||
// Optimization; hide all slides that are three or more steps
|
// Optimization; hide all slides that are three or more steps
|
||||||
// away from the present slide
|
// away from the present slide
|
||||||
if( overviewIsActive() === false ) {
|
if( overviewIsActive() === false ) {
|
||||||
slide.style.display = Math.abs( index - i ) > 3 ? 'none' : 'block';
|
// The distance loops so that it measures 1 between the first
|
||||||
|
// and last slides
|
||||||
|
var distance = Math.abs( ( index - i ) % ( slidesLength - 3 ) ) || 0;
|
||||||
|
|
||||||
|
slide.style.display = distance > 3 ? 'none' : 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
slides[i].classList.remove( 'past' );
|
slides[i].classList.remove( 'past' );
|
||||||
|
|
6
js/reveal.min.js
vendored
6
js/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user