correction to view distance calculation for vertical slides

edit
Hakim El Hattab 2013-08-11 16:27:52 -04:00
parent a96ace5194
commit cc41aa9115
2 changed files with 13 additions and 13 deletions

View File

@ -1587,13 +1587,14 @@ var Reveal = (function(){
// an array // an array
var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ), var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ),
horizontalSlidesLength = horizontalSlides.length, horizontalSlidesLength = horizontalSlides.length,
distance; distanceX,
distanceY;
if( horizontalSlidesLength ) { if( horizontalSlidesLength ) {
// The number of steps away from the present slide that will // The number of steps away from the present slide that will
// be visible // be visible
var viewDistance = isOverview() ? 20 : config.viewDistance; var viewDistance = isOverview() ? 10 : config.viewDistance;
// Limit view distance on weaker devices // Limit view distance on weaker devices
if( isMobileDevice ) { if( isMobileDevice ) {
@ -1606,30 +1607,29 @@ var Reveal = (function(){
var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ), var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ),
verticalSlidesLength = verticalSlides.length; verticalSlidesLength = verticalSlides.length;
// Loops so that it measures 1 between the first and last slides
distanceX = Math.abs( ( indexh - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
if( verticalSlidesLength ) { if( verticalSlidesLength ) {
// Always show the vertical stack itself, even if its child // Always show the vertical stack itself, even if its child
// slides are invisible // slides are invisible
horizontalSlide.style.display = 'block'; horizontalSlide.style.display = 'block';
var oy = getPreviousVerticalIndex( horizontalSlide );
for( var y = 0; y < verticalSlidesLength; y++ ) { for( var y = 0; y < verticalSlidesLength; y++ ) {
var verticalSlide = verticalSlides[y]; var verticalSlide = verticalSlides[y];
var dx = x - indexh, distanceY = x === indexh ? Math.abs( indexv - y ) : Math.abs( y - oy );
dy = y - indexv;
distance = Math.sqrt( dx*dx + dy*dy ); verticalSlide.style.display = ( distanceX + distanceY ) > viewDistance ? 'none' : 'block';
verticalSlide.style.display = distance > viewDistance ? 'none' : 'block';
} }
} }
else { else {
// Loops so that it measures 1 between the first and last slides horizontalSlide.style.display = distanceX > viewDistance ? 'none' : 'block';
distance = Math.abs( ( indexh - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
horizontalSlide.style.display = distance > viewDistance ? 'none' : 'block';
} }
} }

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long