Skip to content

Instantly share code, notes, and snippets.

@AnanthaRajuC
Created July 1, 2015 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnanthaRajuC/a533b63ea282611c8e91 to your computer and use it in GitHub Desktop.
Save AnanthaRajuC/a533b63ea282611c8e91 to your computer and use it in GitHub Desktop.
AngularJS Animations
<body ng-app="todoTest">
<div ng-controller="TodoCtrl">
<div class="container">
<h1 class="page-header text-center">Angular Animations Test</h1>
<form ng-submit="addTodo(newTodo)">
<input type="text" ng-model="newTodo" placeholder="New Todo item goes here" class="form-control" focus/>
</form>
<br />
<div class="list-group">
<div class="list-group-item todo-item" ng-repeat="item in items" ng-class="{ 'todo-complete': item.complete }">
<span class="close" ng-click="removeTodo($index)">&times;</span>
<label>
<input type="checkbox" ng-model="item.complete" />
<span ng-bind="item.text">This is the content of the todo</span>
</label>
</div>
</div>
<button class="btn btn-danger btn-block" ng-click="clearAll()">Clear all items</button>
</div>
</div>
</body>
var app = angular.module("todoTest", ["ngAnimate"]);
app.controller("TodoCtrl", function($scope) {
$scope.items = [{ text: "This is a sample todo", complete: true }];
$scope.newTodo = "";
$scope.addTodo = function() {
$scope.items.push({ text: $scope.newTodo, complete: false });
$scope.newTodo = "";
};
$scope.removeTodo = function(index) {
$scope.items.splice(index, 1);
}
$scope.clearAll = function() {
$scope.items = [];
}
});
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-animate.min.js"></script>
.todo-item {
transition: background-color 0.3s, color 0.6s;
label { display: block; }
&.ng-enter {
animation: fadeInLeft 1s;
}
&.ng-leave {
animation: bounceOut 1s;
}
}
.todo-complete {
background-color: #f3f3f3;
color: #777;
label {
text-decoration: line-through;
}
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment