major cleanup of reader mode code

This commit is contained in:
Hakim El Hattab
2023-10-20 20:23:31 +02:00
parent cc9a36dc25
commit 51acc830f9
6 changed files with 229 additions and 166 deletions

View File

@@ -1578,6 +1578,8 @@ export default function( revealElement, options ) {
indexh = h;
indexv = v;
const slideChanged = currentSlide !== slideElement;
previousSlide = currentSlide;
currentSlide = slideElement;
@@ -1588,6 +1590,17 @@ export default function( revealElement, options ) {
}
}
// Start or stop embedded content like videos and iframes
if( slideChanged ) {
if( previousSlide ) {
slideContent.stopEmbeddedContent( previousSlide );
slideContent.stopEmbeddedContent( previousSlide.slideBackgroundElement );
}
slideContent.startEmbeddedContent( currentSlide );
slideContent.startEmbeddedContent( currentSlide.slideBackgroundElement );
}
requestAnimationFrame( () => {
announceStatus( getStatusText( currentSlide ) );
});
@@ -2132,6 +2145,7 @@ export default function( revealElement, options ) {
// If a slide is specified, return the indices of that slide
if( slide ) {
// In reader mode the original h/x index is stored on the slide
if( reader.isActive() ) {
h = parseInt( slide.getAttribute( 'data-index-h' ), 10 );