allow custom auto-animate matchers to override transition settings

This commit is contained in:
Hakim El Hattab 2020-02-11 10:39:59 +01:00
parent 1c62b808ad
commit 55aab24a5e

View file

@ -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 );