Skip to content

Commit ccb6bf1

Browse files
committed
fix(modal): using cross mode animations
fixes #9323
1 parent 3fd9a20 commit ccb6bf1

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

src/animations/animation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class Animation {
3939
hasCompleted: boolean = false;
4040

4141
constructor(ele?: any, opts?: AnimationOptions, raf?: Function) {
42-
this.element(ele).opts = opts;
42+
this.element(ele);
43+
this.opts = opts;
4344
this._raf = raf || nativeRaf;
4445
}
4546

src/components/modal/modal-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
export interface ModalOptions {
33
showBackdrop?: boolean;
44
enableBackdropDismiss?: boolean;
5+
enterAnimation?: string;
6+
leaveAnimation?: string;
57
}

src/components/modal/modal-transitions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ export class ModalSlideIn extends PageTransition {
1414
const backdrop = new Animation(backdropEle);
1515
const wrapper = new Animation(ele.querySelector('.modal-wrapper'));
1616

17-
backdrop.fromTo('opacity', 0.01, 0.4);
17+
wrapper.beforeStyles({ 'opacity': 1 });
1818
wrapper.fromTo('translateY', '100%', '0%');
1919

20+
backdrop.fromTo('opacity', 0.01, 0.4);
21+
2022
this
2123
.element(this.enteringView.pageRef())
2224
.easing('cubic-bezier(0.36,0.66,0.04,1)')

src/components/modal/modal.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { ViewController } from '../../navigation/view-controller';
1414
*/
1515
export class Modal extends ViewController {
1616
private _app: App;
17+
private _enterAnimation: string;
18+
private _leaveAnimation: string;
1719

1820
constructor(app: App, component: any, data: any, opts: ModalOptions = {}) {
1921
data = data || {};
@@ -24,14 +26,28 @@ export class Modal extends ViewController {
2426

2527
super(ModalCmp, data, null);
2628
this._app = app;
29+
this._enterAnimation = opts.enterAnimation;
30+
this._leaveAnimation = opts.leaveAnimation;
31+
2732
this.isOverlay = true;
2833
}
2934

3035
/**
3136
* @private
3237
*/
33-
getTransitionName(direction: string) {
34-
let key = (direction === 'back' ? 'modalLeave' : 'modalEnter');
38+
getTransitionName(direction: string): string {
39+
let key: string;
40+
if (direction === 'back') {
41+
if (this._leaveAnimation) {
42+
return this._leaveAnimation;
43+
}
44+
key = 'modalLeave';
45+
} else {
46+
if (this._enterAnimation) {
47+
return this._enterAnimation;
48+
}
49+
key = 'modalEnter';
50+
}
3551
return this._nav && this._nav.config.get(key);
3652
}
3753

src/components/modal/test/basic/app-module.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ export class E2EPage {
6767
}
6868

6969
presentModal() {
70-
let modal = this.modalCtrl.create(ModalPassData, { userId: 8675309 });
70+
let modal = this.modalCtrl.create(ModalPassData, { userId: 8675309 }, {
71+
enterAnimation: 'modal-slide-in',
72+
leaveAnimation: 'modal-slide-out'
73+
});
7174
modal.present();
7275

7376
modal.onWillDismiss((data: any) => {
@@ -87,7 +90,10 @@ export class E2EPage {
8790
}
8891

8992
presentToolbarModal() {
90-
this.modalCtrl.create(ToolbarModal).present();
93+
this.modalCtrl.create(ToolbarModal, null, {
94+
enterAnimation: 'modal-md-slide-in',
95+
leaveAnimation: 'modal-md-slide-out'
96+
}).present();
9197
}
9298

9399
presentModalWithInputs() {

0 commit comments

Comments
 (0)