In my project, I am dynamically applying different CSS classes based on the variable 'statetostartwaves'. If the variable is '0', then class 1 (preloader_pause waves) should be used. Otherwise, if it is '1', then class 2 (preloader waves) should be applied.
HTML
<div ng-class="statetostartwaves ===0 ? 'preloader_pause waves':(statetostartwaves ===1 ? 'preloader waves')" >
<span></span>
<span></span>
<span></span>
</div>
Angular App Controller
selektApp.controller('homeController',['$scope','$timeout',function($scope,$timeout) {
$scope.statetostartwaves=0;
$timeout(function(){
$scope.statetostartwaves=1;
,}500);
}]);
CSS Animation Styles
.waves {
opacity:0;
-webkit-animation: second 3s forwards;
-webkit-animation-iteration-count: 1;
-webkit-animation-delay: 1s;
animation: second 2s forwards;
animation-iteration-count: 1;
animation-delay: 1.2s;
position: relative;
}
@-webkit-keyframes second {
0% {
opacity: 1;
}
50% {
opacity: 0.2;
top: -19px;
}
}
@keyframes second {
30% {
opacity: 0;
top:-50px;
}
100% {
opacity: 1;
top: -200px;
}
}
.preloader {
position: relative;
width: 65px;
margin: 0px 0px 0px 130px;
}
.preloader span {
position: absolute;
display: block;
bottom: -300px;
left: 350px;
width: 15px;
height: 15px;
border-radius: 10px;
background: #3498db;
-webkit-animation: preloader .6s infinite ease-in-out;
animation: preloader .6s infinite ease-in-out;
}
.preloader span:nth-child(2) {
left: 390px;
-webkit-animation-delay: 100ms;
animation-delay: 100ms;
}
.preloader span:nth-child(3) {
left: 430px;
-webkit-animation-delay: 200ms;
animation-delay: 200ms;
}
@-webkit-keyframes preloader {
0% {
height: 30px;
-webkit-transform: translateY(15px);
transform: translateY(15px);
background: #3498db;
}
25% {
height: 30px;
-webkit-transform: translateY(15px);
transform: translateY(15px);
background: #3498db;
}
50%,100% {
height: 60px;
-webkit-transform: translateY(30px);
transform: translateY(30px);
background: #3498db;
}
}
@keyframes preloader {
0% {
height: 15px;
-webkit-transform: translateY(0);
transform: translateY(0);
background: #3498db;
}
25% {
height: 90px;
-webkit-transform: translateY(45px);
transform: translateY(45px);
background: #3498db;
}
50%,100% {
height: 15px;
-webkit-transform: translateY(0);
transform: translateY(0);
background: #3498db;
}
}
.preloader_pause {
position: relative;
width: 65px;
margin: 0px 0px 0px 130px;
}
.preloader_pause span {
position: absolute;
display: block;
bottom: -300px;
left: 350px;
width: 15px;
height: 15px;
border-radius: 10px;
background: #3498db;
-webkit-animation: preloader 0s infinite ease-in-out;
animation: preloader 0s infinite ease-in-out;
}
.preloader_pause span:nth-child(2) {
left: 390px;
-webkit-animation-delay: 200ms;
animation-delay: 200ms;
}
.preloader_pause span:nth-child(3) {
left: 430px;
-webkit-animation-delay: 400ms;
animation-delay: 400ms;
}
.preloader_pause span:nth-child(4) {
left: 33px;
-webkit-animation-delay: 600ms;
animation-delay: 600ms;
}
.preloader_pause span:nth-child(5) {
left: 44px;
-webkit-animation-delay: 800ms;
animation-delay: 800ms;
}
.preloader_pause span:nth-child(6) {
left: 55px;
-webkit-animation-delay: 1000ms;
animation-delay: 1000ms;
}
@-webkit-keyframes preloader {
0% {
height: 5px;
-webkit-transform: translateY(0);
transform: translateY(0);
background: #3498db;
}
25% {
height: 30px;
-webkit-transform: translateY(15px);
transform: translateY(15px);
background: #3498db;
}
50%,100% {
height: 5px;
-webkit-transform: translateY(0);
transform: translateY(0);
background: #3498db;
}
}
@keyframes preloader_pause {
0% {
height: 15px;
-webkit-transform: translateY(0);
transform: translateY(0);
background: #3498db;
}
25% {
height: 60px;
-webkit-transform: translateY(30px);
transform: translateY(30px);
background: #3498db;
}
50%,100% {
height: 5px;
-webkit-transform: translateY(0);
transform: translateY(0);
background: #3498db;
}
}