How to flash
shan75 opened this issue · comments
Hi
This is not an issue, but I want to use the basic flash , but it flashes only two times. I want to flash n times. How to do that? Also I want to trigger the flash by some action. How to achieve it?
Can you please explain
Thanks
Unfortunately it's not possible to configure the number of flashes, but here is the animation if you want to copy and customize it to have more than 2 flashes:
export const flash = animation(
animate(
'{{ timing }}s {{ delay }}s',
keyframes([
style({ opacity: 1 }),
style({ opacity: 0 }),
style({ opacity: 1 }),
style({ opacity: 0 }),
style({ opacity: 1 }),
])
),
{ params: { timing: DEFAULT_TIMING, delay: 0 } }
);
About the trigger, you must define the action in the transition. For instance, with the following code, the animation wil be triggered when the flash
property changes from stateA
to stateB
aka this.flash = 'stateB'
:
animations: [
trigger('flash', [transition('stateA => stateB', useAnimation(flash))])
]
Hi Thanks for the details.
I am not able to set the key frames as you have explained, I am very new to angular 4 and, it is not working for me. I have managed to get the animation work based on state. But I am not able to repeat 5 times. Can you please advice. Sorry for trouble
Thanks
animations: [
trigger('flash', [
state('small', style({ opacity: 1})),
state('large', style({ opacity: 0})),
transition('small => large', useAnimation(flash,
{ params: { timing: 5, delay: 1 }
}))
])
]