2014-01-10 33 views
1

ngAnimate單頁應用程序定義:Angular 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'); 
    }); 

我試過,但沒有奏效。無論我對元素做什麼,即使是在示例代碼中刪除類,也會觸發相同的轉換。

回答

2

理論上它應該是可能的。你需要做的是在路由開始時更改容器的類。你可以編寫你自己的指令。代碼將類似於

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中,您可以爲這些類定義不同的轉換。有一件事要記住,這將同時影響進入和離開動畫。