【问题标题】:Angular ngAnimate, how to mix transitions?Angular ngAnimate,如何混合过渡?
【发布时间】:2014-01-29 22:17:16
【问题描述】:

在定义了ngAnimate 的单页应用程序中:

var app= angular.module("demoApp", ['ngRoute','ngAnimate']);

是否可以将一些路由页面设置为 x 过渡而其他页面设置为 y 过渡?

我想混合转换。

更新 1

这个提议:

 $scope.$on('$routeChangeStart', function(event, next, current) {
        var newPath = next.$$route.originalPath;
        ...
        $("#elementID").removeClass('view-animate');
    });

我试过了,但是没有用。无论我对元素做了什么,即使像我在示例代码中所做的那样删除了类,同样的转换总是会触发。

【问题讨论】:

    标签: javascript css angularjs ng-animate


    【解决方案1】:

    理论上应该是可以的。您需要做的是在路由开始时更改容器的类。您可以为此编写自己的指令。代码类似于

    scope.$on('$routeChangeStart', function(event, next, current) {
        var newPath = next.$$route.originalPath;
        // determine the class based on the path
        // set the class on the ng-view div
        // or toggle one class if you need only two different transitions
        element.toggleClass(transitionClass);
    

    在您的 css 中,您可以为这些类定义不同的转换。需要记住的一件事是,这会同时影响进入和离开动画。

    【讨论】:

      猜你喜欢
      • 2013-02-05
      • 1970-01-01
      • 2015-02-21
      • 2013-03-23
      • 2014-06-07
      • 2014-06-03
      • 2011-12-24
      • 2012-12-17
      • 2022-07-21
      相关资源
      最近更新 更多