Chapter 3: Creating removeClass animations with ngClass
HTML
<script src="https://code.angularjs.org/1.3.2/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.2/angular-animate.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<div ng-app="myApp">
<div ng-controller="Ctrl">
<button ng-click="displayToggle=!displayToggle">
Toggle Visibility
</button>
<div class="container">
<span class="prompt">Wake up, Neozdfsdfsdf sfs dfsd fsdfsdfsfsdfsdf...</span>
<div class="cover"
ng-class="{blackout: displayToggle}">
</div>
</div>
</div>
</div>
CSS
.container {
background-color:black;
width:200px;
height:200px;
overflow:hidden;
}
.prompt {
position:absolute;
margin:10px;
font-family:courier;
color:lime;
}
.cover {
position:relative;
width:200px;
height:200px;
left:200px;
background-color:black;
}
.blackout {
left:0;
}
.blackout-remove {
animation: 1s slide-out;
-webkit-animation: 1s slide-out;
}
@keyframes slide-out {
0% {
left:0;
}
100% {
left:200px;
}
}
@-webkit-keyframes slide-out {
0% {
left:0;
}
100% {
left:200px;
}
}
JavaScript
angular.module('myApp', ['ngAnimate'])
.controller('Ctrl', function($scope) {
$scope.displayToggle = false;
});