【发布时间】:2016-07-30 00:38:20
【问题描述】:
我创建了一个简单的吐司系统。我有一个不可见的 (bottom: -50px; position: fixed;) 块:
<div class="toast" ng-class="$root.peekToast.class" ng-bind="$root.peekToast.msg"></div>
然后我在需要 toast 时使用ng-class 添加一个toast-show(带动画)类:
.ew-toast-show {
-webkit-animation: ew-toast-show 0.5s forwards;
-webkit-animation-delay: 0.5s;
animation: ew-toast-show 0.5s forwards;
animation-delay: 500ms;
}
@-webkit-keyframes ew-toast-show {
100% { bottom: 20px; }
}
@keyframes ew-toast-show {
100% { bottom: 20px; }
}
但是,当 toast 准备好关闭时,我希望有一个 toast-hide 类 slides-down toast 替换 toast-show 类。
我试图通过使用-50px 而不是20px 来复制show 动画逻辑。它并不完全奏效。它在向下滑动之前隐藏并显示了块。
正确的做法是什么?
【问题讨论】:
标签: javascript css angularjs animation