forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransition-controller.ts
More file actions
61 lines (49 loc) · 1.55 KB
/
transition-controller.ts
File metadata and controls
61 lines (49 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 { Transition } from './transition';
import { createTransition } from './transition-registry';
import { ViewController } from '../navigation/view-controller';
/**
* @private
*/
@Injectable()
export class TransitionController {
private _ids = 0;
private _trns: {[key: number]: Transition} = {};
constructor(private _config: Config) {}
getRootTrnsId(nav: NavControllerBase): number {
let parent = <NavControllerBase>nav.parent;
while (parent) {
if (isPresent(parent._trnsId)) {
return parent._trnsId;
}
parent = parent.parent;
}
return null;
}
nextId() {
return this._ids++;
}
get(trnsId: number, enteringView: ViewController, leavingView: ViewController, opts: AnimationOptions) {
const trns = createTransition(this._config, opts.animation, enteringView, leavingView, opts);
trns.trnsId = trnsId;
if (!this._trns[trnsId]) {
// we haven't created the root transition yet
this._trns[trnsId] = trns;
} else {
// we already have a root transition created
// add this new transition as a child to the root
this._trns[trnsId].add(trns);
}
return trns;
}
destroy(trnsId: number) {
if (this._trns[trnsId]) {
this._trns[trnsId].destroy();
delete this._trns[trnsId];
}
}
}