1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. (function (factory) {
  2. if (typeof module === "object" && typeof module.exports === "object") {
  3. var v = factory(require, exports);
  4. if (v !== undefined) module.exports = v;
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. define(["require", "exports", "@angular/core", "../config/config", "../util/util", "../platform/platform"], factory);
  8. }
  9. })(function (require, exports) {
  10. "use strict";
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var config_1 = require("../config/config");
  14. var util_1 = require("../util/util");
  15. var platform_1 = require("../platform/platform");
  16. /**
  17. * @hidden
  18. */
  19. var TransitionController = (function () {
  20. function TransitionController(plt, _config) {
  21. this.plt = plt;
  22. this._config = _config;
  23. this._ids = 0;
  24. this._trns = {};
  25. }
  26. TransitionController.prototype.getRootTrnsId = function (nav) {
  27. nav = nav.parent;
  28. while (nav) {
  29. if (util_1.isPresent(nav._trnsId)) {
  30. return nav._trnsId;
  31. }
  32. nav = nav.parent;
  33. }
  34. return null;
  35. };
  36. TransitionController.prototype.nextId = function () {
  37. return this._ids++;
  38. };
  39. TransitionController.prototype.get = function (trnsId, enteringView, leavingView, opts) {
  40. var TransitionClass = this._config.getTransition(opts.animation);
  41. if (!TransitionClass) {
  42. // didn't find a transition animation, default to ios-transition
  43. TransitionClass = this._config.getTransition('ios-transition');
  44. }
  45. var trns = new TransitionClass(this.plt, enteringView, leavingView, opts);
  46. trns.trnsId = trnsId;
  47. if (!this._trns[trnsId]) {
  48. // we haven't created the root transition yet
  49. this._trns[trnsId] = trns;
  50. }
  51. else {
  52. // we already have a root transition created
  53. // add this new transition as a child to the root
  54. this._trns[trnsId].add(trns);
  55. }
  56. return trns;
  57. };
  58. TransitionController.prototype.destroy = function (trnsId) {
  59. var trans = this._trns[trnsId];
  60. if (trans) {
  61. trans.destroy();
  62. delete this._trns[trnsId];
  63. }
  64. };
  65. TransitionController.decorators = [
  66. { type: core_1.Injectable },
  67. ];
  68. /** @nocollapse */
  69. TransitionController.ctorParameters = function () { return [
  70. { type: platform_1.Platform, },
  71. { type: config_1.Config, },
  72. ]; };
  73. return TransitionController;
  74. }());
  75. exports.TransitionController = TransitionController;
  76. });
  77. //# sourceMappingURL=transition-controller.js.map