add isVerticalSlide utility method

This commit is contained in:
Hakim El Hattab 2013-04-29 22:07:09 -04:00
parent 0306e0fa0d
commit 36a8f12127
2 changed files with 21 additions and 6 deletions

View file

@ -932,6 +932,22 @@ var Reveal = (function(){
} }
/**
* Checks if the current or specified slide is vertical
* (nested within another slide).
*
* @param {HTMLElement} slide [optional] The slide to check
* orientation of
*/
function isVerticalSlide( slide ) {
// Prefer slide argument, otherwise use current slide
slide = slide ? slide : currentSlide;
return slide && !!slide.parentNode.nodeName.match( /section/i );
}
/** /**
* Handling the fullscreen functionality via the fullscreen API * Handling the fullscreen functionality via the fullscreen API
* *
@ -1229,7 +1245,7 @@ var Reveal = (function(){
element.style.display = distance > 3 ? 'none' : 'block'; element.style.display = distance > 3 ? 'none' : 'block';
} }
var reverse = config.rtl && !element.parentNode.nodeName.match( /section/gi ); var reverse = config.rtl && !isVerticalSlide( element );
element.classList.remove( 'past' ); element.classList.remove( 'past' );
element.classList.remove( 'present' ); element.classList.remove( 'present' );
@ -1362,7 +1378,6 @@ var Reveal = (function(){
// Highlight fragment directions // Highlight fragment directions
if( currentSlide ) { if( currentSlide ) {
var isVertical = !!currentSlide.parentNode.nodeName.match( /section/gi );
// Always apply fragment decorator to prev/next buttons // Always apply fragment decorator to prev/next buttons
if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } );
@ -1370,7 +1385,7 @@ var Reveal = (function(){
// Apply fragment decorators to directional buttons based on // Apply fragment decorators to directional buttons based on
// what slide axis they are in // what slide axis they are in
if( isVertical ) { if( isVerticalSlide( currentSlide ) ) {
if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } );
if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } ); if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); } );
} }
@ -1576,7 +1591,7 @@ var Reveal = (function(){
// If a slide is specified, return the indices of that slide // If a slide is specified, return the indices of that slide
if( slide ) { if( slide ) {
var isVertical = !!slide.parentNode.nodeName.match( /section/gi ); var isVertical = isVerticalSlide( slide );
var slideh = isVertical ? slide.parentNode : slide; var slideh = isVertical ? slide.parentNode : slide;
// Select all horizontal slides // Select all horizontal slides

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long