import { animate , animation , AnimationTriggerMetadata , AUTO_STYLE , keyframes , style , transition , trigger } from '@angular/animations' ; import { IAnimationOptions , IAttentionSeekerAnimationOptions } from '../common/interfaces' ; import { useAnimationIncludingChildren } from '../common/use-animation-including-children' ; const wobble = ( ) => animation ( [ animate ( '{{duration}}ms {{delay}}ms' , keyframes ( [ style ( { visibility : AUTO_STYLE , transform : 'translate3d(0, 0, 0)' , easing : 'ease' , offset : 0 } ) , style ( { transform : 'translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg)' , easing : 'ease' , offset : 0.15 } ) , style ( { transform : 'translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg)' , easing : 'ease' , offset : 0.3 } ) , style ( { transform : 'translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg)' , easing : 'ease' , offset : 0.45 } ) , style ( { transform : 'translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg)' , easing : 'ease' , offset : 0.6 } ) , style ( { transform : 'translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg)' , easing : 'ease' , offset : 0.75 } ) , style ( { transform : 'translate3d(0, 0, 0)' , easing : 'ease' , offset : 1 } ) ] ) ) ] ) ; const DEFAULT_DURATION = 1000 ; export function wobbleAnimation ( options ? ) { return trigger ( ( options && options . anchor ) || 'wobble' , [ transition ( `0 ${ ( options && options . direction ) || '<=>' } 1` , [ ... useAnimationIncludingChildren ( wobble ( ) , options ) ] , { params : { delay : ( options && options . delay ) || 0 , duration : ( options && options . duration ) || DEFAULT_DURATION } } ) ] ) ; } export function wobbleOnEnterAnimation ( options ? ) { return trigger ( ( options && options . anchor ) || 'wobbleOnEnter' , [ transition ( ':enter' , [ style ( { visibility : 'hidden' } ) , ... useAnimationIncludingChildren ( wobble ( ) , options ) ] , { params : { delay : ( options && options . delay ) || 0 , duration : ( options && options . duration ) || DEFAULT_DURATION } } ) ] ) ; }