fix(modal): using cross mode animations

fixes #9323
This commit is contained in:
Manu Mtz.-Almeida
2016-11-30 13:30:28 +01:00
parent 3fd9a205d7
commit ccb6bf1390
5 changed files with 33 additions and 6 deletions

View File

@ -39,7 +39,8 @@ export class Animation {
hasCompleted: boolean = false;
constructor(ele?: any, opts?: AnimationOptions, raf?: Function) {
this.element(ele).opts = opts;
this.element(ele);
this.opts = opts;
this._raf = raf || nativeRaf;
}

View File

@ -2,4 +2,6 @@
export interface ModalOptions {
showBackdrop?: boolean;
enableBackdropDismiss?: boolean;
enterAnimation?: string;
leaveAnimation?: string;
}

View File

@ -14,9 +14,11 @@ export class ModalSlideIn extends PageTransition {
const backdrop = new Animation(backdropEle);
const wrapper = new Animation(ele.querySelector('.modal-wrapper'));
backdrop.fromTo('opacity', 0.01, 0.4);
wrapper.beforeStyles({ 'opacity': 1 });
wrapper.fromTo('translateY', '100%', '0%');
backdrop.fromTo('opacity', 0.01, 0.4);
this
.element(this.enteringView.pageRef())
.easing('cubic-bezier(0.36,0.66,0.04,1)')

View File

@ -14,6 +14,8 @@ import { ViewController } from '../../navigation/view-controller';
*/
export class Modal extends ViewController {
private _app: App;
private _enterAnimation: string;
private _leaveAnimation: string;
constructor(app: App, component: any, data: any, opts: ModalOptions = {}) {
data = data || {};
@ -24,14 +26,28 @@ export class Modal extends ViewController {
super(ModalCmp, data, null);
this._app = app;
this._enterAnimation = opts.enterAnimation;
this._leaveAnimation = opts.leaveAnimation;
this.isOverlay = true;
}
/**
* @private
*/
getTransitionName(direction: string) {
let key = (direction === 'back' ? 'modalLeave' : 'modalEnter');
getTransitionName(direction: string): string {
let key: string;
if (direction === 'back') {
if (this._leaveAnimation) {
return this._leaveAnimation;
}
key = 'modalLeave';
} else {
if (this._enterAnimation) {
return this._enterAnimation;
}
key = 'modalEnter';
}
return this._nav && this._nav.config.get(key);
}

View File

@ -67,7 +67,10 @@ export class E2EPage {
}
presentModal() {
let modal = this.modalCtrl.create(ModalPassData, { userId: 8675309 });
let modal = this.modalCtrl.create(ModalPassData, { userId: 8675309 }, {
enterAnimation: 'modal-slide-in',
leaveAnimation: 'modal-slide-out'
});
modal.present();
modal.onWillDismiss((data: any) => {
@ -87,7 +90,10 @@ export class E2EPage {
}
presentToolbarModal() {
this.modalCtrl.create(ToolbarModal).present();
this.modalCtrl.create(ToolbarModal, null, {
enterAnimation: 'modal-md-slide-in',
leaveAnimation: 'modal-md-slide-out'
}).present();
}
presentModalWithInputs() {