Selaa lähdekoodia

data-autoslide attribute takes precedence over video duration

Hakim El Hattab 5 vuotta sitten
vanhempi
commit
b1e5db0ec9
4 muutettua tiedostoa jossa 19 lisäystä ja 16 poistoa
  1. 0 0
      dist/reveal.esm.js
  2. 0 0
      dist/reveal.js
  3. 6 3
      examples/media.html
  4. 13 13
      js/reveal.js

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/reveal.esm.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/reveal.js


+ 6 - 3
examples/media.html

@@ -31,6 +31,11 @@
 					<h2 style="color: #fff;">Iframe Background</h2>
 				</section>
 
+				<section>
+					<h2>Video</h2>
+					<video src="https://static.slid.es/site/homepage/v1/homepage-video-editor.mp4" data-autoplay></video>
+				</section>
+
 				<section>
 					<h2>Auto-playing audio</h2>
 					<audio src="assets/beeping.wav" data-autoplay></audio>
@@ -59,9 +64,7 @@
 
 		<script src="../dist/reveal.js"></script>
 		<script>
-			Reveal.initialize({
-				transition: 'linear'
-			});
+			Reveal.initialize();
 		</script>
 
 	</body>

+ 13 - 13
js/reveal.js

@@ -2067,21 +2067,21 @@ export default function( revealElement, options ) {
 			}
 			else {
 				autoSlide = config.autoSlide;
-			}
 
-			// If there are media elements with data-autoplay,
-			// automatically set the autoSlide duration to the
-			// length of that media. Not applicable if the slide
-			// is divided up into fragments.
-			// playbackRate is accounted for in the duration.
-			if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) {
-				Util.queryAll( currentSlide, 'video, audio' ).forEach( el => {
-					if( el.hasAttribute( 'data-autoplay' ) ) {
-						if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) {
-							autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000;
+				// If there are media elements with data-autoplay,
+				// automatically set the autoSlide duration to the
+				// length of that media. Not applicable if the slide
+				// is divided up into fragments.
+				// playbackRate is accounted for in the duration.
+				if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) {
+					Util.queryAll( currentSlide, 'video, audio' ).forEach( el => {
+						if( el.hasAttribute( 'data-autoplay' ) ) {
+							if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) {
+								autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000;
+							}
 						}
-					}
-				} );
+					} );
+				}
 			}
 
 			// Cue the next auto-slide if:

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä