Im trying to trigger animation when the value of countAllOrders
changes. Specifically, im trying to set the margin of list using keyframs in angular animation. My html is as follows:
<ul class="digits" [@ordersValue]="countAllOrders" #digits>
<li>0</li>
<li>1</li>
<li>{{ countAllOrders }}</li>
</ul>
and the animation implementtation is:
animations: [
trigger('ordersValue', [
transition(':increment', [
animate('1s', keyframes([style({ marginTop: '-7em' })])),
]),
]),
],
the initial css of .digits
sets margin-top:0em
. during animation the desired effect works but instead of finishig with margin top's value to be -7em
it ends with 0em
.
According to some answers I found here I tried to use state
trigger('ordersValue', [
state(':increment', style({ marginTop: '-7em' })),
transition(':increment', [
style({ marginTop: '-7em' }),
animate('1s', style('*')),
]),
]),
css:
.digits {
list-style-type: none;
margin-top: 0em;
animation-duration: 1s;
animation-timing-function: ease;
animation-fill-mode: forwards;
}
but that didnt help, any idea how to tackle this one?