|
3054 | 3054 |
|
3055 | 3055 | }
|
3056 | 3056 |
|
| 3057 | + /** |
| 3058 | + * Called when the given slide is within the configured view |
| 3059 | + * distance. Shows the slide element and loads any content |
| 3060 | + * that is set to load lazily (data-src). |
| 3061 | + * |
| 3062 | + * @param {HTMLElement} slide Slide to show |
| 3063 | + */ |
3057 | 3064 | /**
|
3058 | 3065 | * Called when the given slide is within the configured view
|
3059 | 3066 | * distance. Shows the slide element and loads any content
|
|
3098 | 3105 |
|
3099 | 3106 | // If the background contains media, load it
|
3100 | 3107 | if( background.hasAttribute( 'data-loaded' ) === false ) {
|
| 3108 | + background.setAttribute( 'data-loaded', 'true' ); |
3101 | 3109 |
|
3102 | 3110 | var backgroundImage = slide.getAttribute( 'data-background-image' ),
|
3103 | 3111 | backgroundVideo = slide.getAttribute( 'data-background-video' ),
|
|
3107 | 3115 |
|
3108 | 3116 | // Images
|
3109 | 3117 | if( backgroundImage ) {
|
3110 |
| - |
3111 | 3118 | background.style.backgroundImage = 'url('+ backgroundImage +')';
|
3112 |
| - background.setAttribute( 'data-loaded', 'true' ); |
3113 |
| - |
3114 | 3119 | }
|
3115 | 3120 | // Videos
|
3116 | 3121 | else if ( backgroundVideo && !isSpeakerNotes() ) {
|
| 3122 | + var video = document.createElement( 'video' ); |
3117 | 3123 |
|
3118 |
| - if( !isOverview() ) { |
3119 |
| - |
3120 |
| - var video = document.createElement( 'video' ); |
3121 |
| - video.setAttribute( 'autoplay', '' ); |
3122 |
| - video.setAttribute( 'playsinline', '' ); |
3123 |
| - |
3124 |
| - if( backgroundVideoLoop ) { |
3125 |
| - video.setAttribute( 'loop', '' ); |
3126 |
| - } |
3127 |
| - |
3128 |
| - if( backgroundVideoMuted ) { |
3129 |
| - video.muted = true; |
3130 |
| - } |
3131 |
| - |
3132 |
| - // Support comma separated lists of video sources |
3133 |
| - backgroundVideo.split( ',' ).forEach( function( source ) { |
3134 |
| - video.innerHTML += '<source src="'+ source +'">'; |
3135 |
| - } ); |
3136 |
| - |
3137 |
| - background.appendChild( video ); |
| 3124 | + if( backgroundVideoLoop ) { |
| 3125 | + video.setAttribute( 'loop', '' ); |
| 3126 | + } |
3138 | 3127 |
|
3139 |
| - background.setAttribute( 'data-loaded', 'true' ); |
| 3128 | + if( backgroundVideoMuted ) { |
| 3129 | + video.muted = true; |
| 3130 | + } |
3140 | 3131 |
|
| 3132 | + // Inline video playback works (at least in Mobile Safari) as |
| 3133 | + // long as the video is muted and the `playsinline` attribute is |
| 3134 | + // present |
| 3135 | + if( isMobileDevice ) { |
| 3136 | + video.muted = true; |
| 3137 | + video.autoplay = true; |
| 3138 | + video.setAttribute( 'playsinline', '' ); |
3141 | 3139 | }
|
3142 | 3140 |
|
| 3141 | + // Support comma separated lists of video sources |
| 3142 | + backgroundVideo.split( ',' ).forEach( function( source ) { |
| 3143 | + video.innerHTML += '<source src="'+ source +'">'; |
| 3144 | + } ); |
| 3145 | + |
| 3146 | + background.appendChild( video ); |
3143 | 3147 | }
|
3144 | 3148 | // Iframes
|
3145 | 3149 | else if( backgroundIframe ) {
|
3146 |
| - |
3147 | 3150 | var iframe = document.createElement( 'iframe' );
|
3148 | 3151 | iframe.setAttribute( 'allowfullscreen', '' );
|
3149 | 3152 | iframe.setAttribute( 'mozallowfullscreen', '' );
|
|
3164 | 3167 | iframe.style.maxWidth = '100%';
|
3165 | 3168 |
|
3166 | 3169 | background.appendChild( iframe );
|
3167 |
| - |
3168 |
| - background.setAttribute( 'data-loaded', 'true' ); |
3169 |
| - |
3170 | 3170 | }
|
3171 |
| - else { |
3172 |
| - |
3173 |
| - background.setAttribute( 'data-loaded', 'true' ); |
3174 |
| - |
3175 |
| - } |
3176 |
| - |
3177 | 3171 | }
|
| 3172 | + |
3178 | 3173 | }
|
3179 | 3174 |
|
3180 | 3175 | }
|
|
3415 | 3410 | * the targeted slide.
|
3416 | 3411 | *
|
3417 | 3412 | * @param {HTMLElement} element
|
3418 |
| - * @param {boolean} autoplay Optionally override the |
3419 |
| - * autoplay setting of media elements |
3420 | 3413 | */
|
3421 |
| - function stopEmbeddedContent( element, autoplay ) { |
| 3414 | + function stopEmbeddedContent( element ) { |
3422 | 3415 |
|
3423 | 3416 | if( element && element.parentNode ) {
|
3424 | 3417 | // HTML5 media elements
|
|
0 commit comments