1
當動畫ng-if
和ngAnimate
時,我遇到問題。我有兩個不同的容器相互替換,fadeInLeft新元素和fadeOutRight舊元素。但是,在動畫期間,第二個容器向下移動。CSS動畫在動畫過程中向下移動第二個元素
這是我的問題(在全屏幕模式顯示,看確切的問題)的簡化示例:
var app = angular.module("MyApp", ['ngAnimate']);
app.controller("MyController", function($scope, $interval) {
$scope.show = true;
$interval(function() {
$scope.show = !$scope.show;
}, 3000);
});
.box {
height: 200px;
}
.box.ng-enter {
animation: fadeInLeft 1.0s;
}
.box.ng-leave {
animation: fadeOutRight 1.0s;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular-animate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.4.0/animate.css" />
<div ng-app="MyApp" ng-controller="MyController">
<div ng-if="show" class="box" style="background:red"></div>
<div ng-if="!show" class="box" style="background:blue"></div>
</div>
謝謝您的回答!但對於你的解決方案,當我將內容添加到動畫'div'並且fadeOutRight動畫未顯示時,我仍然遇到問題。 [plunkr](http://plnkr.co/edit/3DoSKhGbqqlVImkT3b3Y?p=preview) – boindiil
我剛更新了我的答案:) –
謝謝,它的工作原理! – boindiil