allow custom auto-animate matchers to override transition settings

master
Hakim El Hattab 2020-02-11 10:39:59 +01:00
parent 1c62b808ad
commit 55aab24a5e
1 changed files with 13 additions and 5 deletions

View File

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