How can I use ng-animate with ui-view rather than ng-view?

后端 未结 8 1776
自闭症患者
自闭症患者 2020-12-13 00:26

I am using angular-ui-router with angularJS v1.2 and would like to implement custom page transitions.
How can I use ng-animate with ui-view (from angular-ui-router) rath

8条回答
  •  长情又很酷
    2020-12-13 00:55

    Looks like this is fixed with UI Router 0.2.8. I'm using AngularJS v1.2.7.

    For an example, just add the "slide" class to your ui-view

    And use the following css for your animation.

    .slide {
        -webkit-transition: -webkit-transform .7s ease-in-out;
        -moz-transition: -moz-transform .7s ease-in-out;
        -o-transition: -o-transform .7s ease-in-out;
        transition: transform .7s ease-in-out;
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    
    .slide.ng-enter {
        -webkit-transform: translateX(-100%);
        transform: translateX(-100%);
    }
    
    .slide.ng-enter.ng-enter-active, .slide.ng-leave {
        position: absolute;
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    
    .slide.ng-leave.ng-leave-active {
        -webkit-transform: translateX(100%);
        transform: translateX(100%);
    }
    

    Additionally, some animations seemed to have some weird behavior because of $uiViewScroll. I worked around it by adding autoscroll="false" to my ui-view element.

提交回复
热议问题