To give an example of what I am trying to do:
I have an angular material table which is being sourced from a class extending DataSource
. The connect method on the DataSource
is subscribing to some data (e.g. Firestore).
As the data changes elsewhere the material table updates the table on the screen. No problem there. What I really want to do, is flash the change on the screen (or indicate via an animation), that this particular item has changed.
A real world example would be premiership football games, as the scores change during the game, the score changing from a subscription (observable) would use some animation (colour change for 1s example) to give feedback to the user.
I have tried:
<ng-container matColumnDef="lost">
<mat-header-cell *matHeaderCellDef>Score</mat-header-cell>
<mat-cell *matCellDef="let sc" [@changeState]="sc.score">{{ sc.score }</mat-cell>
</ng-container>
with the sc.score
being the trigger
state.
and have animated something like :
trigger('changeState', [
state('inactive', style({
backgroundColor: '#ff0000',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#00ff00',
transform: 'scale(1.1)'
})),
transition('* <=> *', animate('5000ms ease-in'))
])
(This is not the exact one I need, but just playing with the animate).
As the value change being the state, I used a transition of * <=> *
, hopefully means anything to anything. As for the states, I have no idea what to place in the state names, need something like :beforechange
and :afterchange
. Even without the states, I was expecting the value to ease in after 5s (but it happens immediate.
I have looked around the internet and I am surprised that I could not find an example of someone wanting the same (unless I'm bad at Google searching).