sliding between route transition angularjs

心已入冬 提交于 2019-12-02 22:09:12

For anyone googleing this....

Add the classes ng-enter/ng-leave/.ng-enter-active/.ng-leave-active to your css classes. Example

.slide-animate.ng-enter, .slide-animate.ng-leave{
 -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
  -moz-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
   -o-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
      transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
 }


.slide-animate.ng-enter.ng-enter-active {
 position: absolute;
 left: 1300px;
}

.slide-animate.ng-enter {
 left: 0;
}

.slide-animate.ng-leave.ng-leave-active {
 position: absolute;
 left: -1700px;
 }

.slide-animate.ng-leave {
 right: 0;
 }

Egghead.io also has some great video on animation if you want a in depth tutorial

The above answers are correct... but I would add that having routes with a trailing slash:

.when('/introduction/', ...)

Will break your transitions... Angular immediately redirects to '/introduction' which breaks the transition. so be sure to use:

.when('/introduction', ...)

Took me like 5 hours to finally determine why my transitions wouldn't work.. when my test projects and all the examples worked great.

If you are using Angular 1.2.x then ngAnimate directive is no longer needed. Angular animate currently uses .ng-enter and .ng-leave as hooks to add your transformations. The below article I found very helpful in learning about the new way of doing animations in just the way youre trying to accomplish ( by animating the routes aka each partial that is inserted into the ngview directive).

Animating AngularJS Apps: ngView

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!