【发布时间】:2015-06-23 17:09:35
【问题描述】:
我制作了显示/隐藏消息列表的动画。见this plunk。但是,当从列表中删除消息时,如何调整它以制作动画?
我的 CSS:
.messages-active.messages {
max-height: 50px;
}
.messages {
-webkit-transition: max-height 1s;
-moz-transition: max-height 1s;
-ms-transition: max-height 1s;
-o-transition: max-height 1s;
transition: max-height 1s;
background-color: AntiqueWhite;
overflow: hidden;
max-height: 0;
}
我的索引文件(使用 Angular):
<body ng-app="app" ng-controller="TestCtrl as test">
<button ng-click="test.toggle = !test.toggle">Show messages</button>
(current: {{test.toggle}})
<div class="messages" ng-class="{ 'messages-active': test.toggle }" ng-repeat="message in test.messages">
{{message}} <a href ng-click="test.remove($index)">remove</a>
</div>
</body>
【问题讨论】:
-
我不认为 css 动画可以解决这个问题,因为这些消息是 AngularJS 的一部分,所以你必须尝试 javascript,Angular 本身来为它们设置动画。
标签: angularjs css animation css-animations