Forráskód Böngészése

fix previous bg video playing in background

Hakim El Hattab 1 éve
szülő
commit
421da63750
5 módosított fájl, 36 hozzáadás és 33 törlés
  1. 0 0
      dist/reveal.esm.js
  2. 0 0
      dist/reveal.esm.js.map
  3. 0 0
      dist/reveal.js
  4. 0 0
      dist/reveal.js.map
  5. 36 33
      js/controllers/backgrounds.js

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/reveal.esm.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/reveal.esm.js.map


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/reveal.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/reveal.js.map


+ 36 - 33
js/controllers/backgrounds.js

@@ -322,16 +322,47 @@ export default class Backgrounds {
 
 		} );
 
+		// The previous background may refer to a DOM element that has
+		// been removed after a presentation is synced & bgs are recreated
+		if( this.previousBackground && !this.previousBackground.closest( 'body' ) ) {
+			this.previousBackground = null;
+		}
+
+		if( currentBackground && this.previousBackground ) {
+
+			// Don't transition between identical backgrounds. This
+			// prevents unwanted flicker.
+			let previousBackgroundHash = this.previousBackground.getAttribute( 'data-background-hash' );
+			let currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
+
+			if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== this.previousBackground ) {
+				this.element.classList.add( 'no-transition' );
+
+				// If multiple slides have the same background video, carry
+				// the <video> element forward so that it plays continuously
+				// across multiple slides
+				const currentVideo = currentBackground.querySelector( 'video' );
+				const previousVideo = this.previousBackground.querySelector( 'video' );
+
+				if( currentVideo && previousVideo ) {
+
+					const currentVideoParent = currentVideo.parentNode;
+					const previousVideoParent = previousVideo.parentNode;
+
+					// Swap the two videos
+					previousVideoParent.appendChild( currentVideo );
+					currentVideoParent.appendChild( previousVideo );
+
+				}
+			}
+
+		}
+
 		// Stop content inside of previous backgrounds
 		if( this.previousBackground ) {
 
 			this.Reveal.slideContent.stopEmbeddedContent( this.previousBackground, { unloadIframes: !this.Reveal.slideContent.shouldPreload( this.previousBackground ) } );
 
-			// Clear the previous background if it was removed from DOM
-			if( !this.previousBackground.closest( 'body' ) ) {
-				this.previousBackground = null;
-			}
-
 		}
 
 		// Start content in the current background
@@ -353,34 +384,6 @@ export default class Backgrounds {
 
 			}
 
-			// Don't transition between identical backgrounds. This
-			// prevents unwanted flicker.
-			let previousBackgroundHash = this.previousBackground ? this.previousBackground.getAttribute( 'data-background-hash' ) : null;
-			let currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
-			if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== this.previousBackground ) {
-				this.element.classList.add( 'no-transition' );
-
-				// If multiple slides have the same background video, we carry
-				// the <video> element forward so that it doesn't restart
-				const currentVideo = currentBackground.querySelector( 'video' );
-				if( currentVideo && this.previousBackground ) {
-					const previousVideo = this.previousBackground.querySelector( 'video' );
-
-					if( previousVideo ) {
-						const currentVideoParent = currentVideo.parentNode;
-						const previousVideoParent = previousVideo.parentNode;
-
-						// Swap the two videos
-						previousVideoParent.appendChild( currentVideo );
-						currentVideoParent.appendChild( previousVideo );
-
-						if( config.autoPlayMedia !== false ) {
-							previousVideo.play();
-						}
-					}
-				}
-			}
-
 			this.previousBackground = currentBackground;
 
 		}

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott