diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2011-12-22 22:41:19 -0800 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2011-12-22 22:41:19 -0800 |
commit | f6dc5312980150c68510a955e4ce8e5d2691b412 (patch) | |
tree | 773804a64f705d2fda3472efca98a3084aa21d1d /js | |
parent | 01000e14783e71d3f17a12a68807dbfccb64cec8 (diff) | |
download | fosdem-2018-presentation-f6dc5312980150c68510a955e4ce8e5d2691b412.tar fosdem-2018-presentation-f6dc5312980150c68510a955e4ce8e5d2691b412.tar.gz |
slides three or more steps away from current are now hidden
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/js/reveal.js b/js/reveal.js index 79437ae..3dddf7d 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -282,16 +282,23 @@ var Reveal = (function(){ index = Math.max(Math.min(index, slides.length - 1), 0); slides[index].setAttribute('class', 'present'); - - // Any element previous to index is given the 'past' class - slides.slice(0, index).map(function(element){ - element.setAttribute('class', 'past'); - }); - - // Any element subsequent to index is given the 'future' class - slides.slice(index + 1).map(function(element){ - element.setAttribute('class', 'future'); - }); + + for( var i = 0; i < slides.length; i++ ) { + var slide = slides[i]; + + // Optimization; hide all slides that are three or more steps + // away from the present slide + slide.style.display = Math.abs( index - i ) > 3 ? 'none' : 'block'; + + if( i < index ) { + // Any element previous to index is given the 'past' class + slide.setAttribute('class', 'past'); + } + else if( i > index ) { + // Any element subsequent to index is given the 'future' class + slide.setAttribute('class', 'future'); + } + } } else { // Since there are no slides we can't be anywhere beyond the |