mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
@ -39,7 +39,8 @@ export class Animation {
|
|||||||
hasCompleted: boolean = false;
|
hasCompleted: boolean = false;
|
||||||
|
|
||||||
constructor(ele?: any, opts?: AnimationOptions, raf?: Function) {
|
constructor(ele?: any, opts?: AnimationOptions, raf?: Function) {
|
||||||
this.element(ele).opts = opts;
|
this.element(ele);
|
||||||
|
this.opts = opts;
|
||||||
this._raf = raf || nativeRaf;
|
this._raf = raf || nativeRaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,4 +2,6 @@
|
|||||||
export interface ModalOptions {
|
export interface ModalOptions {
|
||||||
showBackdrop?: boolean;
|
showBackdrop?: boolean;
|
||||||
enableBackdropDismiss?: boolean;
|
enableBackdropDismiss?: boolean;
|
||||||
|
enterAnimation?: string;
|
||||||
|
leaveAnimation?: string;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,11 @@ export class ModalSlideIn extends PageTransition {
|
|||||||
const backdrop = new Animation(backdropEle);
|
const backdrop = new Animation(backdropEle);
|
||||||
const wrapper = new Animation(ele.querySelector('.modal-wrapper'));
|
const wrapper = new Animation(ele.querySelector('.modal-wrapper'));
|
||||||
|
|
||||||
backdrop.fromTo('opacity', 0.01, 0.4);
|
wrapper.beforeStyles({ 'opacity': 1 });
|
||||||
wrapper.fromTo('translateY', '100%', '0%');
|
wrapper.fromTo('translateY', '100%', '0%');
|
||||||
|
|
||||||
|
backdrop.fromTo('opacity', 0.01, 0.4);
|
||||||
|
|
||||||
this
|
this
|
||||||
.element(this.enteringView.pageRef())
|
.element(this.enteringView.pageRef())
|
||||||
.easing('cubic-bezier(0.36,0.66,0.04,1)')
|
.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 {
|
export class Modal extends ViewController {
|
||||||
private _app: App;
|
private _app: App;
|
||||||
|
private _enterAnimation: string;
|
||||||
|
private _leaveAnimation: string;
|
||||||
|
|
||||||
constructor(app: App, component: any, data: any, opts: ModalOptions = {}) {
|
constructor(app: App, component: any, data: any, opts: ModalOptions = {}) {
|
||||||
data = data || {};
|
data = data || {};
|
||||||
@ -24,14 +26,28 @@ export class Modal extends ViewController {
|
|||||||
|
|
||||||
super(ModalCmp, data, null);
|
super(ModalCmp, data, null);
|
||||||
this._app = app;
|
this._app = app;
|
||||||
|
this._enterAnimation = opts.enterAnimation;
|
||||||
|
this._leaveAnimation = opts.leaveAnimation;
|
||||||
|
|
||||||
this.isOverlay = true;
|
this.isOverlay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
getTransitionName(direction: string) {
|
getTransitionName(direction: string): string {
|
||||||
let key = (direction === 'back' ? 'modalLeave' : 'modalEnter');
|
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);
|
return this._nav && this._nav.config.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,10 @@ export class E2EPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
presentModal() {
|
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.present();
|
||||||
|
|
||||||
modal.onWillDismiss((data: any) => {
|
modal.onWillDismiss((data: any) => {
|
||||||
@ -87,7 +90,10 @@ export class E2EPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
presentToolbarModal() {
|
presentToolbarModal() {
|
||||||
this.modalCtrl.create(ToolbarModal).present();
|
this.modalCtrl.create(ToolbarModal, null, {
|
||||||
|
enterAnimation: 'modal-md-slide-in',
|
||||||
|
leaveAnimation: 'modal-md-slide-out'
|
||||||
|
}).present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentModalWithInputs() {
|
presentModalWithInputs() {
|
||||||
|
Reference in New Issue
Block a user