null check background
parent
1391253cb8
commit
fbf999ec81
42
js/reveal.js
42
js/reveal.js
|
@ -2326,29 +2326,31 @@
|
||||||
// Show the corresponding background element
|
// Show the corresponding background element
|
||||||
var indices = getIndices( slide );
|
var indices = getIndices( slide );
|
||||||
var background = getSlideBackground( indices.h, indices.v );
|
var background = getSlideBackground( indices.h, indices.v );
|
||||||
background.style.display = 'block';
|
if( background ) {
|
||||||
|
background.style.display = 'block';
|
||||||
|
|
||||||
// If the background contains media, load it
|
// If the background contains media, load it
|
||||||
if( background.hasAttribute( 'data-loaded' ) === false ) {
|
if( background.hasAttribute( 'data-loaded' ) === false ) {
|
||||||
background.setAttribute( 'data-loaded', 'true' );
|
background.setAttribute( 'data-loaded', 'true' );
|
||||||
|
|
||||||
var backgroundImage = slide.getAttribute( 'data-background-image' ),
|
var backgroundImage = slide.getAttribute( 'data-background-image' ),
|
||||||
backgroundVideo = slide.getAttribute( 'data-background-video' );
|
backgroundVideo = slide.getAttribute( 'data-background-video' );
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
if( backgroundImage ) {
|
if( backgroundImage ) {
|
||||||
background.style.backgroundImage = 'url('+ backgroundImage +')';
|
background.style.backgroundImage = 'url('+ backgroundImage +')';
|
||||||
}
|
}
|
||||||
// Videos
|
// Videos
|
||||||
else if ( backgroundVideo ) {
|
else if ( backgroundVideo ) {
|
||||||
var video = document.createElement( 'video' );
|
var video = document.createElement( 'video' );
|
||||||
|
|
||||||
// Support comma separated lists of video sources
|
// Support comma separated lists of video sources
|
||||||
backgroundVideo.split( ',' ).forEach( function( source ) {
|
backgroundVideo.split( ',' ).forEach( function( source ) {
|
||||||
video.innerHTML += '<source src="'+ source +'">';
|
video.innerHTML += '<source src="'+ source +'">';
|
||||||
} );
|
} );
|
||||||
|
|
||||||
background.appendChild( video );
|
background.appendChild( video );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2366,7 +2368,9 @@
|
||||||
// Hide the corresponding background element
|
// Hide the corresponding background element
|
||||||
var indices = getIndices( slide );
|
var indices = getIndices( slide );
|
||||||
var background = getSlideBackground( indices.h, indices.v );
|
var background = getSlideBackground( indices.h, indices.v );
|
||||||
background.style.display = 'none';
|
if( background ) {
|
||||||
|
background.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue