transition-controller.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { Injectable } from '@angular/core';
  2. import { Config } from '../config/config';
  3. import { isPresent } from '../util/util';
  4. import { Platform } from '../platform/platform';
  5. /**
  6. * @hidden
  7. */
  8. var TransitionController = (function () {
  9. function TransitionController(plt, _config) {
  10. this.plt = plt;
  11. this._config = _config;
  12. this._ids = 0;
  13. this._trns = {};
  14. }
  15. TransitionController.prototype.getRootTrnsId = function (nav) {
  16. nav = nav.parent;
  17. while (nav) {
  18. if (isPresent(nav._trnsId)) {
  19. return nav._trnsId;
  20. }
  21. nav = nav.parent;
  22. }
  23. return null;
  24. };
  25. TransitionController.prototype.nextId = function () {
  26. return this._ids++;
  27. };
  28. TransitionController.prototype.get = function (trnsId, enteringView, leavingView, opts) {
  29. var TransitionClass = this._config.getTransition(opts.animation);
  30. if (!TransitionClass) {
  31. // didn't find a transition animation, default to ios-transition
  32. TransitionClass = this._config.getTransition('ios-transition');
  33. }
  34. var trns = new TransitionClass(this.plt, enteringView, leavingView, opts);
  35. trns.trnsId = trnsId;
  36. if (!this._trns[trnsId]) {
  37. // we haven't created the root transition yet
  38. this._trns[trnsId] = trns;
  39. }
  40. else {
  41. // we already have a root transition created
  42. // add this new transition as a child to the root
  43. this._trns[trnsId].add(trns);
  44. }
  45. return trns;
  46. };
  47. TransitionController.prototype.destroy = function (trnsId) {
  48. var trans = this._trns[trnsId];
  49. if (trans) {
  50. trans.destroy();
  51. delete this._trns[trnsId];
  52. }
  53. };
  54. TransitionController.decorators = [
  55. { type: Injectable },
  56. ];
  57. /** @nocollapse */
  58. TransitionController.ctorParameters = function () { return [
  59. { type: Platform, },
  60. { type: Config, },
  61. ]; };
  62. return TransitionController;
  63. }());
  64. export { TransitionController };
  65. //# sourceMappingURL=transition-controller.js.map