Bläddra i källkod

allow custom auto-animate matchers to override transition settings

Hakim El Hattab 5 år sedan
förälder
incheckning
55aab24a5e
1 ändrade filer med 13 tillägg och 5 borttagningar
  1. 13 5
      js/reveal.js

+ 13 - 5
js/reveal.js

@@ -3854,12 +3854,14 @@
 			delete element.dataset.autoAnimateTarget;
 		} );
 
-		var animationOptions = getAutoAnimateOptions( toSlide );
+		var animationOptions = getAutoAnimateOptions( toSlide, {
 
-		// If our slides are centered vertically, we need to
-		// account for their difference in position when
-		// calculating deltas for animated elements
-		if( config.center ) animationOptions.offsetY = fromSlide.offsetTop - toSlide.offsetTop;
+			// If our slides are centered vertically, we need to
+			// account for their difference in position when
+			// calculating deltas for animated elements
+			offsetY: config.center ? fromSlide.offsetTop - toSlide.offsetTop : 0
+
+		} );
 
 		// Set our starting state
 		fromSlide.dataset.autoAnimate = 'pending';
@@ -3933,6 +3935,12 @@
 		// like transition easing, duration and delay
 		animationOptions = getAutoAnimateOptions( to, animationOptions );
 
+		// Individual transition settings can be overridden via
+		// element options
+		if( typeof elementOptions.delay !== 'undefined' ) animationOptions.delay = elementOptions.delay;
+		if( typeof elementOptions.duration !== 'undefined' ) animationOptions.duration = elementOptions.duration;
+		if( typeof elementOptions.easing !== 'undefined' ) animationOptions.easing = elementOptions.easing;
+
 		var fromProps = getAutoAnimatableProperties( 'from', from, elementOptions ),
 			toProps = getAutoAnimatableProperties( 'to', to, elementOptions );