fix issue where slide transitions were still running for auto-animated slides in Safari

This commit is contained in:
Hakim El Hattab 2020-03-30 13:29:52 +02:00
parent 34ab7ded55
commit fe75be1cff
2 changed files with 39 additions and 30 deletions

4
dist/reveal.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1212,6 +1212,36 @@ export default function( revealElement, options ) {
indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h ); indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h );
indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v ); indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v );
// Dispatch an event if the slide changed
let slideChanged = ( indexh !== indexhBefore || indexv !== indexvBefore );
// Ensure that the previous slide is never the same as the current
if( !slideChanged ) previousSlide = null;
// Find the current horizontal slide and any possible vertical slides
// within it
let currentHorizontalSlide = horizontalSlides[ indexh ],
currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
// Store references to the previous and current slides
currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
let autoAnimateTransition = false;
// Detect if we're moving between two auto-animated slides
if( slideChanged && previousSlide && currentSlide && !overview.isActive() ) {
// If this is an auto-animated transition, we disable the
// regular slide transition
//
// Note 20-03-2020:
// This needs to happen before we update slide visibility,
// otherwise transitions will still run in Safari.
if( previousSlide.hasAttribute( 'data-auto-animate' ) && currentSlide.hasAttribute( 'data-auto-animate' ) ) {
autoAnimateTransition = true;
dom.slides.classList.add( 'disable-slide-transitions' );
}
}
// Update the visibility of slides now that the indices have changed // Update the visibility of slides now that the indices have changed
updateSlidesVisibility(); updateSlidesVisibility();
@ -1222,26 +1252,11 @@ export default function( revealElement, options ) {
overview.update(); overview.update();
} }
// Find the current horizontal slide and any possible vertical slides
// within it
let currentHorizontalSlide = horizontalSlides[ indexh ],
currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
// Store references to the previous and current slides
currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
// Show fragment, if specified // Show fragment, if specified
if( typeof f !== 'undefined' ) { if( typeof f !== 'undefined' ) {
fragments.goto( f ); fragments.goto( f );
} }
// Dispatch an event if the slide changed
let slideChanged = ( indexh !== indexhBefore || indexv !== indexvBefore );
if (!slideChanged) {
// Ensure that the previous slide is never the same as the current
previousSlide = null;
}
// Solves an edge case where the previous slide maintains the // Solves an edge case where the previous slide maintains the
// 'present' class when navigating between adjacent vertical // 'present' class when navigating between adjacent vertical
// stacks // stacks
@ -1318,21 +1333,15 @@ export default function( revealElement, options ) {
cueAutoSlide(); cueAutoSlide();
// Auto-animation // Auto-animation
if( slideChanged && previousSlide && currentSlide && !overview.isActive() ) { if( autoAnimateTransition ) {
// Skip the slide transition between our two slides setTimeout( () => {
// when auto-animating individual elements dom.slides.classList.remove( 'disable-slide-transitions' );
if( previousSlide.hasAttribute( 'data-auto-animate' ) && currentSlide.hasAttribute( 'data-auto-animate' ) ) { }, 0 );
dom.slides.classList.add( 'disable-slide-transitions' );
setTimeout( () => { if( config.autoAnimate ) {
dom.slides.classList.remove( 'disable-slide-transitions' ); // Run the auto-animation between our slides
}, 0 ); autoAnimate.run( previousSlide, currentSlide );
if( config.autoAnimate ) {
// Run the auto-animation between our slides
autoAnimate.run( previousSlide, currentSlide );
}
} }
} }