I'm trying to mock a refresh for a list that I have. So when a user clicks refresh, the list fades in to let users know a new GET request was made.
html
<div ng-controller="ModalDemoCtrl">
<ul ng-repeat="friend in friends" class="animated" ng-class="{fadeIn: refresh === true}">
<li>{{friend}}</li>
</ul>
<button ng-click="refresh=!refresh"> Fade me in every time </button>
</div>
css
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes fadeIn {
0% {opacity: 0;}
100% {opacity: 1;}
}
@keyframes fadeIn {
0% {opacity: 0;}
100% {opacity: 1;}
}
.fadeIn {
-webkit-animation-name: fadeIn;
animation-name: fadeIn;
}
and of course the js
angular.module('plunker', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal, $log) {
$scope.friends = ['andy', 'randy', 'bambi'] ;
};
Here's a working plnkr: http://plnkr.co/edit/R0Gv2T?p=info
My issue is the way I have it, the user has to click twice to fade in the list in after clicking it once because the variable refresh has to be set back to false before being set back to true. Is there anywhere through pure css to accomplish this? I've tried setting scope variables in the controller and calling on click function but I'm just confused at this point. I'm open to any solution