[英]AngularJS v1.2 ngAnimate and ngView
i'm wondering why this does not work like excepted. 我想知道为什么这不像例外。 Simply try to fade/in/out the content of the ng-view.
只需尝试淡入/淡出/退出ng-view的内容。 Not done much with css3 animations.
css3动画做得不多。 Maybe there is a mistake in my thoughts.
也许我的想法有误。
Please check out this Link (Plunker) 请查看此链接 (Plunker)
First off, in angular 1.2 the ng-animate directive is deprecated. 首先,在角度1.2中,不推荐使用ng-animate指令。 You can simply put the class you want on there.
你可以简单地把你想要的课程放在那里。 So we make a class called pageFade that looks like:
所以我们创建了一个名为pageFade的类,它看起来像:
.pageFade.ng-enter, .pageFade.ng-leave{
//transition styles
}
.pageFade.ng-enter{
opacity: 0;
}
.pageFade.ng-enter-active{
opacity:1;
}
.pageFade.ng-leave{
opacity:1;
}
.pageFade.ng-leave-active{
opacity:0;
}
Then, in the view: 然后,在视图中:
<div ng-view class="pageFade"></div>
Ok, I think I figured it out. 好吧,我想我弄明白了。 The directive changed.
指令改变了。 Check the docs here:
查看这里的文档:
http://code.angularjs.org/1.2.0rc1/docs/api/ngAnimate http://code.angularjs.org/1.2.0rc1/docs/api/ngAnimate
Here is a forked plunkr that demonstrates: 这是一个分叉的plunkr,演示:
http://plnkr.co/edit/MJZhZW2gCrTBE5XWWJEj?p=preview http://plnkr.co/edit/MJZhZW2gCrTBE5XWWJEj?p=preview
To those who may have the same question I created a simple demonstration of how ngView
can transition with animations. 对于那些可能有同样问题的人,我创建了一个关于
ngView
如何通过动画过渡的简单演示。 Check out this demo project . 看看这个演示项目 。
In short you basically only need to define animation rules in CSS using ng-enter
, ng-enter-active
, ng-leave
, ng-leave-active
classes. 简而言之,您基本上只需要使用
ng-enter
, ng-enter-active
, ng-leave
, ng-leave-active
类在CSS中定义动画规则。 Also remember to include ngAnimate
dependency to your module. 还要记住在模块中包含
ngAnimate
依赖项。
Hope it helps someone. 希望它可以帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.