slides three or more steps away from current are now hidden

This commit is contained in:
Hakim El Hattab 2011-12-22 22:41:19 -08:00
parent 01000e1478
commit f6dc531298
1 changed files with 17 additions and 10 deletions

View File

@ -282,16 +282,23 @@ var Reveal = (function(){
index = Math.max(Math.min(index, slides.length - 1), 0); index = Math.max(Math.min(index, slides.length - 1), 0);
slides[index].setAttribute('class', 'present'); slides[index].setAttribute('class', 'present');
// Any element previous to index is given the 'past' class for( var i = 0; i < slides.length; i++ ) {
slides.slice(0, index).map(function(element){ var slide = slides[i];
element.setAttribute('class', 'past');
}); // Optimization; hide all slides that are three or more steps
// away from the present slide
// Any element subsequent to index is given the 'future' class slide.style.display = Math.abs( index - i ) > 3 ? 'none' : 'block';
slides.slice(index + 1).map(function(element){
element.setAttribute('class', 'future'); 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 { else {
// Since there are no slides we can't be anywhere beyond the // Since there are no slides we can't be anywhere beyond the