在我的代碼中,我試圖創建多個div,其中包含一個隱藏按鈕。點擊這個按鈕後,相應的div應該消失,並且它下面的div應該到達頂部(即它們應該通過一些動畫填充由消失的div創建的空間)。向ng-repeat添加幻燈片動畫
這裏是我的html代碼:
<body ng-app="task" ng-controller="repeat">
<div ng-repeat='x in array' ng-hide="x.show">
<p>{{ x.text }}
</p>
<button ng-click="toggle($index)">Hide</button>
</div>
</body>
我的js文件包含以下內容:
var app = angular.module('task');
app.controller('repeat',function($scope){
$scope.array = [{
show: true,
text:'Sample Text 1'},
{
show: true,
text:'Sample Text 2'},
{
show: true,
text:'Sample Text 3'}];
$scope.toggle = function(){
$scope.array[index].show = false ;
};
})
而且在我的CSS我有以下代碼:
.ng-hide-add { animation:1s fade ease; }
@keyframes fade{
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
我有看了很多張貼在網上的滑塊動畫,並試圖使它們適應我的程序,但卻慘敗到了現在。
你能告訴我應該添加什麼樣的代碼來使動畫成爲可能。真的很感激你的迴應。