var app = angular.module('plunker', ['ngAnimate']);
app.controller('MainCtrl', function($scope) {
$scope.listA = [{id:1}, {id:2}, {id:3}, {id:4}, {id:5}];
$scope.listB = [{id:6}];
$scope.moveToListB = function(item) {
$scope.listB.push(item);
$scope.listA.splice($scope.listA.indexOf(item), 1);
};
$scope.moveToListA = function(item) {
$scope.listA.push(item);
$scope.listB.splice($scope.listB.indexOf(item), 1);
};
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.2/angular.js" data-semver="1.4.3"></script>
<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.2/angular-animate.js" data-semver="1.4.3"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<div class="lists">
<ul class="list" title="List A">
<li class="item" ng-repeat="item in listA" ng-click="moveToListB(item)"><span class="item-contents" ng-animate-ref="{{ item.id }}">Item: {{ item.id }}</span></li>
</ul>
<ul class="list" title="List B">
<li class="item" ng-repeat="item in listB" ng-click="moveToListA(item)"><span class="item-contents" ng-animate-ref="{{ item.id }}">Item: {{ item.id }}</span></li>
</ul>
</div>
</body>
</html>
* {
box-sizing: border-box;
}
body {
font-family: Roboto, Helvetica, Arial;
font-size: 12px;
}
.lists {
display: flex;
min-height: 150px;
}
.list:before {
content: attr(title);
background: #eeeeee;
display: block;
padding: 10px;
font-weight: bold;
margin-bottom: 10px;
}
.list {
width: 200px;
border: 1px solid #eeeeee;
padding: 0 0 10px 0;
}
.list + .list {
border-left: none;
}
.item {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.item {
cursor: pointer;
display: block;
margin: 0;
padding: 0;
width: 150px;
height: 30px;
overflow: hidden;
}
.item:hover {
color: blue;
}
.item-contents {
display: block;
width: 200px;
height: 30px;
line-height: 30px;
padding: 0 10px;
}
/* Contents are cloned and position transitioned between the lists */
.item-contents.ng-anchor-out {
/* No "out" transition: the item moving accross the page is exactly how it
appears in the source location */
}
.item-contents.ng-anchor-in {
transition: 0.2s linear all;
}
/* The item height is transitioned so space appears/disappears gradually in each list */
.item.ng-enter {
transition:0.1s linear all;
height: 0;
}
.item.ng-enter.ng-enter-active {
height: 30px;
}
.item.ng-leave {
transition: 0.1s linear all;
height: 30px;
}
.item.ng-leave.ng-leave-active {
height: 0;
}