From 345ec01f191675ae06af0eaec62fe3d7068a361c Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Thu, 27 Feb 2020 08:45:19 +0100 Subject: [PATCH] only transition properties that have changed --- js/reveal.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 08ecbf6..6ec56dc 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3886,7 +3886,7 @@ unmatchedElement.dataset.autoAnimateTarget = 'unmatched'; } ); - css.push( '[data-auto-animate="running"] [data-auto-animate-target="unmatched"] { transition: all '+ (animationOptions.duration*0.8) +'s ease '+ (animationOptions.duration*0.2) +'s; }' ); + css.push( '[data-auto-animate="running"] [data-auto-animate-target="unmatched"] { transition: opacity '+ (animationOptions.duration*0.8) +'s ease '+ (animationOptions.duration*0.2) +'s; }' ); } // Setting the whole chunk of CSS at once is the most @@ -4016,15 +4016,18 @@ var css = ''; + var toStyleProperties = Object.keys( toProps.styles ); + // Only create animate this element IF at least one style // property has changed - if( Object.keys( toProps.styles ).length > 0 ) { + if( toStyleProperties.length > 0 ) { // Instantly move to the 'from' state fromProps.styles['transition'] = 'none'; // Animate towards the 'to' state toProps.styles['transition'] = 'all '+ options.duration +'s '+ options.easing + ' ' + options.delay + 's'; + toProps.styles['transition-property'] = toStyleProperties.join( ', ' ); // Build up our custom CSS. We need to override inline styles // so we need to make our styles vErY IMPORTANT!1!!