mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
@ -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;
|
||||
}
|
||||
|
||||
|
@ -2,4 +2,6 @@
|
||||
export interface ModalOptions {
|
||||
showBackdrop?: boolean;
|
||||
enableBackdropDismiss?: boolean;
|
||||
enterAnimation?: string;
|
||||
leaveAnimation?: string;
|
||||
}
|
||||
|
@ -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)')
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user