import { Injectable } from '@angular/core' ; import { AnimationOptions } from '../animations/animation' ; import { Config } from '../config/config' ; import { isPresent } from '../util/util' ; import { NavControllerBase } from '../navigation/nav-controller-base' ; import { Platform } from '../platform/platform' ; import { Transition } from './transition' ; import { ViewController } from '../navigation/view-controller' ; hidden @ Injectable ( ) export class TransitionController { private _ids = 0 ; private _trns : { [ key ] : Transition ; } = { } ; constructor ( public plt , private _config ) { } getRootTrnsId ( nav ) { nav = < NavControllerBase > nav . parent ; while ( nav ) { if ( isPresent ( nav . _trnsId ) ) { return nav . _trnsId ; } nav = nav . parent ; } return null ; } nextId ( ) { return this . _ids ++ ; } get ( trnsId , enteringView , leavingView , opts ) { let TransitionClass = this . _config . getTransition ( opts . animation ) ; if ( ! TransitionClass ) { TransitionClass = this . _config . getTransition ( 'ios-transition' ) ; } const trns = new TransitionClass ( this . plt , enteringView , leavingView , opts ) ; trns . trnsId = trnsId ; if ( ! this . _trns [ trnsId ] ) { this . _trns [ trnsId ] = trns ; } else { this . _trns [ trnsId ] . add ( trns ) ; } return trns ; } destroy ( trnsId ) { const trans = this . _trns [ trnsId ] ; if ( trans ) { trans . destroy ( ) ; delete this . _trns [ trnsId ] ; } } }