disregard v index when there is no vertical slides/backgrounds in getSlide/getSlideBackground

This commit is contained in:
Hakim El Hattab 2014-04-27 15:04:37 +02:00
parent 902e36c022
commit c58096ea99
1 changed files with 5 additions and 2 deletions

View File

@ -2645,12 +2645,15 @@ var Reveal = (function(){
}
/**
* Returns the slide element matching the specified index.
*/
function getSlide( x, y ) {
var horizontalSlide = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR )[ x ];
var verticalSlides = horizontalSlide && horizontalSlide.querySelectorAll( 'section' );
if( typeof y === 'number' ) {
if( verticalSlides && verticalSlides.length && typeof y === 'number' ) {
return verticalSlides ? verticalSlides[ y ] : undefined;
}
@ -2669,7 +2672,7 @@ var Reveal = (function(){
var horizontalBackground = document.querySelectorAll( '.backgrounds>.slide-background' )[ x ];
var verticalBackgrounds = horizontalBackground && horizontalBackground.querySelectorAll( '.slide-background' );
if( typeof y === 'number' ) {
if( verticalBackgrounds && verticalBackgrounds.length && typeof y === 'number' ) {
return verticalBackgrounds ? verticalBackgrounds[ y ] : undefined;
}