UNPKG

3.05 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = Object.setPrototypeOf ||
3 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5 return function (d, b) {
6 extendStatics(d, b);
7 function __() { this.constructor = d; }
8 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9 };
10})();
11import { Animation } from '../animations/animation';
12import { isPresent } from '../util/util';
13import { PageTransition } from './page-transition';
14var TRANSLATEY = 'translateY';
15var OFF_BOTTOM = '40px';
16var CENTER = '0px';
17var SHOW_BACK_BTN_CSS = 'show-back-button';
18var MDTransition = (function (_super) {
19 __extends(MDTransition, _super);
20 function MDTransition() {
21 return _super !== null && _super.apply(this, arguments) || this;
22 }
23 MDTransition.prototype.init = function () {
24 _super.prototype.init.call(this);
25 var plt = this.plt;
26 var enteringView = this.enteringView;
27 var leavingView = this.leavingView;
28 var opts = this.opts;
29 // what direction is the transition going
30 var backDirection = (opts.direction === 'back');
31 if (enteringView) {
32 if (backDirection) {
33 this.duration(isPresent(opts.duration) ? opts.duration : 200).easing('cubic-bezier(0.47,0,0.745,0.715)');
34 }
35 else {
36 this.duration(isPresent(opts.duration) ? opts.duration : 280).easing('cubic-bezier(0.36,0.66,0.04,1)');
37 this.enteringPage
38 .fromTo(TRANSLATEY, OFF_BOTTOM, CENTER, true)
39 .fromTo('opacity', 0.01, 1, true);
40 }
41 if (enteringView.hasNavbar()) {
42 var enteringPageEle = enteringView.pageRef().nativeElement;
43 var enteringNavbarEle = enteringPageEle.querySelector('ion-navbar');
44 var enteringNavBar = new Animation(plt, enteringNavbarEle);
45 this.add(enteringNavBar);
46 var enteringBackButton = new Animation(plt, enteringNavbarEle.querySelector('.back-button'));
47 this.add(enteringBackButton);
48 if (enteringView.enableBack()) {
49 enteringBackButton.beforeAddClass(SHOW_BACK_BTN_CSS);
50 }
51 else {
52 enteringBackButton.beforeRemoveClass(SHOW_BACK_BTN_CSS);
53 }
54 }
55 }
56 // setup leaving view
57 if (leavingView && backDirection) {
58 // leaving content
59 this.duration(opts.duration || 200).easing('cubic-bezier(0.47,0,0.745,0.715)');
60 var leavingPage = new Animation(plt, leavingView.pageRef());
61 this.add(leavingPage.fromTo(TRANSLATEY, CENTER, OFF_BOTTOM).fromTo('opacity', 1, 0));
62 }
63 };
64 return MDTransition;
65}(PageTransition));
66export { MDTransition };
67//# sourceMappingURL=transition-md.js.map
\No newline at end of file